0

IM 使用 NCommon 和 NHibernate,并想使用 StruceMap 作为我的 IOC。没有人知道如何使用 StructureMap 注册 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);
4

1 回答 1

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);
于 2011-02-08T17:14:45.270 回答