【问题标题】:StructureMap 3 Breaking ChangeStructureMap 3 重大变化
【发布时间】:2014-04-22 05:10:51
【问题描述】:

在以前版本的 StructureMap 中,我有这样的代码:

_container.Configure(config => 
    config
        .For<ILogger>.Use<TLogger>.Ctor<string>("loggerName")
        .Is((IContext ctx) => ctx.Root.RequestedType.ToString))

使用它,我能够将类名传递给我的记录器,这在自动布线场景中非常有用。

更新到StructureMap 3后,上面的代码显示错误,我找不到适合StructureMap 3的代码。

TL;DR; Context.Root 在哪里?如何在 StructureMap 3 中访问它?

【问题讨论】:

    标签: c# .net structuremap structuremap3


    【解决方案1】:

    看来我一开始就错了。

    代替Context.Root,我可以使用Context.ParentType 来完成我想要的。

    此链接中提供的示例:http://docs.structuremap.net/UsingSessionContext.htm#section1(记录器示例)帮助我找到了解决方案。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-06-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-10-24
      相关资源
      最近更新 更多