The syntax in 2.6 is:
c.For<ISomeObject>().LifecycleIs(new HttpSessionLifecycle()).Use<SomeObject>();
Question
How to set session scope for plugin in StructureMap 2.6?
In previous versions it is done this way:
For<ISomeObject>().CacheBy(StructureMap.InstanceScope.HttpSession).Use<SomeObject>();
However, Visual Studio displays a warning telling that the CacheBy
method is deprecated, and that LifecycleIs
method can be used instead.
La solution
The syntax in 2.6 is:
c.For<ISomeObject>().LifecycleIs(new HttpSessionLifecycle()).Use<SomeObject>();
Autres conseils
I believe this will do the trick:
For<ISomeObject>()
.HttpContextScoped()
.Use<SomeObject>();