If I want to specify a constructor argument I need to specify the argument name as string. Unfortunately, this is no开发者_StackOverflowt very refactoring friendly. Is there any way to get around this limitation?
See http://www.planetgeek.ch/2011/05/28/ninject-constructor-selection-preview/ . The next release of Ninject will support to type safely define constructor arguments.
Do:
string s = "my string"
kernel.Bind<IMyInterface>().ToConstructor(x => new MyObject(s));
where MyObject implements IMyInterface.
精彩评论