开发者

Set instance lifecycle with StructureMap convention based registration

开发者 https://www.devze.com 2023-03-08 08:37 出处:网络
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 :

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 (HybridHtt开发者_如何转开发pOrThreadLocalScope) 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());
}
0

精彩评论

暂无评论...
验证码 换一张
取 消