我有两个依赖于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个实现:FirstRepository
和SecondRepository
。
如何配置容器以使用FirstController
和FirstRepository
SecondController
来解析SecondRepository
?
答案 0 :(得分:2)
您可以使用不同的名称注册2实现,然后在调用Resolve方法时可以传递名称。 http://castleproject.org/container/documentation/trunk/manual/windsortypedocs/Generated_IWindsorContainer.html#IWindsorContainer_Methods5