开发者

ConstructorArguments without magic strings

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜