.net - 在 Unity 中使用委托(delegate)解析实例

标签 .net unity-container enterprise-library structuremap

拥有 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/

相关文章:

c# - wpf - 当未选择关联的单选按钮时,我应该如何自动将文本框变灰?

c# - 在 Unity.MVC4 或 Unity(3.0) 中找不到 PerRequestLifetimeManager 类

entity-framework - 使用Unity,如何注册泛型的类型映射?

c# - 如何在 WinForms 中将字典绑定(bind)到组合框?

c# - Visual Studio 中 Goto 定义和 Goto 实现的区别

c# - UserStore 每个 HttpRequest 的 Unity IoC 生命周期

c# - 'globally'如何捕获对象实例中抛出的异常

c# - 简单企业库控制台应用程序拒绝编译

c# - 您使用的是 Microsoft 企业库吗?

c# - 获取 Firefox 网址?