I'm trying to use StructureMap 2.6.1 to register all my repositories at once using the convention based registration. See the code bellow :

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

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

Thanks.

有帮助吗?

解决方案

Have you tried:

x.Scan(s =>
{
    s.TheCallingAssembly();
    s.IncludeNamespaceContainingType<RepositoryRegistration>();
    s.SingleImplementationsOfInterface().OnAddedPluginTypes(t => t.HybridHttpOrThreadLocalScoped());
}
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top