我有以下代码如何使用提供商Ninject
public class Something {
[Inject]
public Configuration config {get;set;} //singleton
[Inject]
public Provider<WindowHandler> windowsProvider { get; set; } //NOT singleton
public void Search(string text) {
WindowHandler handler = windowsProvider.Create(xxxxxx);
//use the new handler that was created
}
}
但似乎提供商需要一个IContext这里我把XXXXXX。不应该使用从内核引导和创建Something.cs时的IContext。提供者的no参数Create方法在哪里? (我是从Guice陆地角度来的,它会像上面那样编码)。
所以问题是如何正确地做到这一点?
感谢, 院长
Func正是我一直在寻找的东西。在2.0版本中我们使用的版本是否没有办法做到这一点? –
2012-01-03 21:57:57
请参阅http://stackoverflow.com/questions/4840157/does-ninject-support-func-auto-generated-factory/4851885#4851885 – 2012-01-04 00:05:57