假设我有以下设置
public interface IDocuments {}
public interface IPeople {}
public class Documents : IDocuments
{
public Documents(IRepository repo){ ... };
}
public class People : IPeople
{
public People(IRepository repo) { ... }
}
public class Controller1
{
public Controller1(IDocuments documents){}
}
public class Controller2
{
public Controller2(IDocuments documents, IPeople people){}
}
如何设置StructureMap以将不同的IRepository瞬态实例注入Controller1和Controller2的依赖链中。
所以澄清一下:
应该有2个IRepository实例。
第一个实例将被注入到controller1的文档实例中。
第二个实例将被注入到controller2的Documents and People实例中。