Frage

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.

War es hilfreich?

Lösung

The syntax in 2.6 is:

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

Andere Tipps

I believe this will do the trick:

    For<ISomeObject>()
        .HttpContextScoped()
        .Use<SomeObject>();
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top