1

我的问题是我想为一个接口注册两种类型:

我检查了这篇文章: https ://groups.google.com/forum/#!msg/structuremap-users/2T_WTAjRVJ8/HKsELqJEOi4J
https://groups.google.com/forum/#!topic/structuremap-users/ 75-1AV1boMw

For<IPageManager>().Singleton().Use<PageManager>().Named("pageManager");
For<IPageManager>().Singleton().Use<EnhancedPageManager>().Named("enhancedPageManager");

在我的控制器中:

public class ValuesController
{
    public ValuesController(IPageManager pageManger)
    {
        // Here I want to be instance of page Manager 
    }
}

public class PagesController
{
    public PagesController(IPageManager enhancedPageManger)
    {
        // Here I want to be instance of enhancedPageManger
    }
}

但问题是我总是收到enhancedPageManger 的实例。
如何解决?

在文档中有配置示例,但没有用法:http ://structuremap.github.io/glossary/#sec3

var container = new Container(c =>
{
   c.For<IFoo>().Use<Foo>();
   c.For<IFoo>().Add<SomeOtherFoo>();
});
4

0 回答 0