0
我用结构图4.5.1在我的ASP.NET MVC 5.x的Web应用程序,我做扫描接口实现并与下面的代码添加HybridHttpOrThreadLocalScoped()
为所有这些:使用HybridHttpOrThreadLocalScoped的所有实例
public static class SmObjectFactory
{
private static readonly Lazy<StructureMap.Container> _containerBuilder =
new Lazy<StructureMap.Container>(DefaultContainer, LazyThreadSafetyMode.ExecutionAndPublication);
public static IContainer Container => _containerBuilder.Value;
private static StructureMap.Container DefaultContainer()
{
return new StructureMap.Container(config =>
{
config.Scan(scanner =>
{
scanner.AssemblyContainingType(typeof(IPostService));
scanner.WithDefaultConventions();
scanner.SingleImplementationsOfInterface()
.OnAddedPluginTypes(expression =>
expression.HybridHttpOrThreadLocalScoped());
});
});
}
}
- 当我使用此代码,
HybridHttpOrThreadLocalScoped()
这也增加了对所有Interfacs是固有IDisposable
接口?如果答案是否定的,我该怎么做? - 当我Sholud不使用
HybridHttpOrThreadLocalScoped()
?
最佳答案Thanks @VahidN –