How to set session scope for plugin in StructureMap 2.6?

How to set session scope for plugin in StructureMap 2.6?

In previous versions, this is done as follows:

For<ISomeObject>().CacheBy(StructureMap.InstanceScope.HttpSession).Use<SomeObject>(); 

However, Visual Studio displays a warning that the CacheBy method is CacheBy date, and the LifecycleIs method can be used instead.

+4
source share
2 answers

Syntax in 2.6:

 c.For<ISomeObject>().LifecycleIs(new HttpSessionLifecycle()).Use<SomeObject>(); 
+4
source

I believe this will do the trick:

  For<ISomeObject>() .HttpContextScoped() .Use<SomeObject>(); 
-1
source

All Articles