2011-02-08 58 views
0

即时通讯使用NCommon与NHibernate,并希望使用StruceMap作为我的IOC。没有人知道如何使用StructureMap注册NCommon?如何使用StruceMap注册NCommon?

这是关于NCommon的信息。

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

下面是如何与温莎城堡进行

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(container); 

回答

0

像这样的东西应该做的工作:

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);