Search code examples
c#dependency-injectionstructuremapstructuremap3

What is the equivalent of HybridHttpOrThreadLocalScoped in structure map 3?


With structuremap 2.6.4.1 my container is configured like this:

existingContainer.Configure(expression =>
{
    expression.For<IDocumentSession>()                    
        .HybridHttpOrThreadLocalScoped()
        .Use(container =>
        {
            var store = container.GetInstance<IDocumentStore>();                        
            return store.OpenSession();
         });
}

HybridHttpOrThreadLocalScoped does not exist in structure map 3 so my question is, what is the equivalent configuration in structuremap 3?


Solution

  • As of StructureMap 3, anything HttpContext related lives within a separate Nuget package called StructureMap.Web which can be found here.

    The reason for this is StructureMap 3 is now PLC (Portalble Class Library) compliant, so splitting web-related lifecycles into its own package makes sense.