Asp.net mvc 4 如何解决Castle Windsor工厂中的依赖关系?

Asp.net mvc 4 如何解决Castle Windsor工厂中的依赖关系?,asp.net-mvc-4,dependency-injection,castle-windsor,factory-pattern,Asp.net Mvc 4,Dependency Injection,Castle Windsor,Factory Pattern,我读到卡斯特林德索尔的工厂,但我搞不清楚。希望有人能帮助我。 我在MVC4项目中有一个类型化工厂 public interface IOrderProcessorFactory { T Create<T>(string ProcessorName) where T : IOrderProcessor; void Release(object service); IOrderProcessor GetTakeAway(); IOrderProcess

我读到卡斯特林德索尔的工厂,但我搞不清楚。希望有人能帮助我。 我在MVC4项目中有一个类型化工厂

public interface IOrderProcessorFactory
{
    T Create<T>(string ProcessorName) where T : IOrderProcessor;

    void Release(object service);

    IOrderProcessor GetTakeAway();
    IOrderProcessor GetInLocal();

}
我得到了正确的一个,一个叫“外卖”的。 但对于这一点,我必须知道它的类型。换句话说,我想调用工厂get方法并传递一个“name”,工厂返回正确的名称

例如,在伪代码中,我希望

TakeAwayOrderProcessor processor1 = factory.GetMeProcessorCalled("TakeAway")
InLocalOrderProcessor processor2 = factory.GetMeProcessorCalled("InLocal")
我知道我可以将参数传递给构造函数,但是我必须“手动”选择它,如果名称是this,则返回this-one

温莎有没有办法像StructureMap那样自动完成这项工作:

ObjectFactory.GetNamedInstance<IOrderProcessor>("InLocal");
ObjectFactory.GetNamedInstance(“InLocal”);
您需要一个

TakeAwayOrderProcessor processor1 = factory.GetMeProcessorCalled("TakeAway")
InLocalOrderProcessor processor2 = factory.GetMeProcessorCalled("InLocal")
ObjectFactory.GetNamedInstance<IOrderProcessor>("InLocal");