注册几种相同的接口

当向容器注册类型时,Castle 使用类的类型来解决。如果特定类型有多个注册,则必须设置 Name 属性:

public void Install(IWindsorContainer container, IConfigurationStore store)
{
    container.Register(
        Component.For<IFoo>().ImplementedBy<Foo>().Named("Registration1"),
        Component.For<IBar>().ImplementedBy<Bar().Named("Registration2"));
}