註冊幾種相同的介面

當向容器註冊型別時,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"));
}