如何在StructureMap 3中调用HybridHttpOrThreadLocalScoped

时间:2014-12-22 12:57:55

标签: structuremap structuremap3

我正在尝试从Structuremap 2.6.4.1迁移到3.1.4.143,但我无法弄清楚如何处理HybridHttpOrThreadLocalScoped。我找不到任何SO Q / A似乎对我有用......

我有以下代码:

using StructureMap;
using StructureMap.Web;

ObjectFactory.Configure( x =>
{
    x.For<IRepository<Person>>()
        .HybridHttpOrThreadLocalScoped() // Need the repo to survive for the duration of the thread!
        .Use<Repository_Stub<Person>>()
        .Ctor<IEnumerable<IEntity>>( "seed" ).Is( persons );
} );

给了我这个错误:

'StructureMap.Configuration.DSL.Expressions.CreatePluginFamilyExpression<IRepository<Person>>' 
does not contain a definition for 'HybridHttpOrThreadLocalScoped' and no extension method
'HybridHttpOrThreadLocalScoped' accepting a first argument of type
StructureMap.Configuration.DSL.Expressions.CreatePluginFamilyExpression<IRepository<Person>>'
could be found (are you missing a using directive or an assembly reference?)

有没有新方法可以调用HybridHttpOrThreadLocalScoped?

Thansk提前!

1 个答案:

答案 0 :(得分:4)

HybridHttpOrThreadLocalScoped已移至名为Structuremap.Web的单独nuget包中。

可以通过在Nuget Package Console中运行Install-Package structuremap.web来安装它。 See this post了解更多信息。