拥有 Unity,自 2011 年 2 月起,improved this delegate story与 StructureMap 实现对等?
最佳答案
是的。实际上,这与 Unity 1.0 作为注入(inject)工厂扩展一起提供,因此博客文章关于不存在该功能是错误的。
在 Unity 2.0 中,故事变得容易多了。你可以做:
container.RegisterType<IWhatever>(
new InjectionFactory(container => whateverFunctionYouWant()));
这会导致临时注册;你可以使用任何你想要的生命周期管理器。
关于.net - 在 Unity 中使用委托(delegate)解析实例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11023761/