3

我有 2 个控制器依赖于ISomeService

public class FirstController
{
    public FirstController(ISomeService someService)
    {
    }
}

public class SecondController
{
    public SecondController(ISomeService someService)
    {
    }
}

ISomeService有一个实现,这取决于IRepository

public class SomeService : ISomeService
{
    public SomeService(IRepository repository)
    {
    }
}

IRepository有 2 个实现:FirstRepositorySecondRepository.

如何配置容器以解决FirstControllerwithFirstRepositorySecondControllerwith SecondRepository

4

1 回答 1

2

您可以使用不同的名称注册 2 个实现,然后可以在调用 Resolve 方法时传递名称。http://castleproject.org/container/documentation/trunk/manual/windsortypedocs/Generated_IWindsorContainer.html#IWindsorContainer_Methods5

检查温莎文档中的此部分

于 2012-05-13T12:00:30.013 回答