【发布时间】:2012-01-03 17:33:54
【问题描述】:
我有以下代码
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
}
}
但 Provider 似乎在我放置 xxxxxx 的地方使用了 IContext。不应该使用我从内核引导并创建Something.cs时的IContext。 Provider上的无参数Create方法在哪里??? (我来自 Guice 土地的观点,它会像上面那样编码)。
所以问题是我该如何正确地做到这一点?
谢谢, 院长
【问题讨论】: