开发者

How to register NCommon with StruceMap?

开发者 https://www.devze.com 2023-02-09 07:32 出处:网络
IM using NCommon with NHibernate and would like to use StruceMap as my IOC. Doesnt anyone know how to register NCommon with StructureMap?

IM using NCommon with NHibernate and would like to use StruceMap as my IOC. Doesnt anyone know how to register NCommon with StructureMap?

Here is the info on NCommon.

https://github.com/riteshrao/ncommon/

Here is how its done with Castle Windsor

    foreach (var type in types)
            container.Register(Component.For<IController>().ImplementedBy(type)
                                        .LifeStyle.Transient
                                        .Named(type.Name.Replace("Controller", "")));

        var containerAdapter = new NCommon.ContainerAdapter.CastleWindsor.WindsorContainerAdapter(contain开发者_运维技巧er);


Something like this should do the job:

containter.Configure(c => {
  foreach (var type in types)
    c.For<IController>()
     .Use(type)
     .Named(type.Name.Replace("Controller", ""));
});

var containerAdapter = new NCommon.ContainerAdapter.StructureMap.StructureMapContainerAdapter(container);
0

精彩评论

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

关注公众号