Setting an Instance Lifecycle with Registration Based on StructureMap

I am trying to use StructureMap 2.6.1 to register all of my repositories at once using convention-based registration. See below code:

x.Scan(s =>
{
    s.TheCallingAssembly();
    s.IncludeNamespaceContainingType<RepositoryRegistration>();
    s.SingleImplementationsOfInterface();
}

This works, but now I'm trying to add a lifecycle (HybridHttpOrThreadLocalScope) to all registered types. Is this possible without rewriting the SingleImplementationsOfInterface convention from scratch, and if so, how?

Thank.

+3
source share
1 answer

You tried:

x.Scan(s =>
{
    s.TheCallingAssembly();
    s.IncludeNamespaceContainingType<RepositoryRegistration>();
    s.SingleImplementationsOfInterface().OnAddedPluginTypes(t => t.HybridHttpOrThreadLocalScoped());
}
+8
source

All Articles