如何将RegisterType用于实现多个接口的类?

kin*_*ngo 1 .net c# dependency-injection castle-windsor

鉴于:

public interface IFeedOperations : IOperationsWithPreInstalledData
{
    ...
}

public class FeedOperations : IFeedOperations
{
}
Run Code Online (Sandbox Code Playgroud)

如何将RegisterType用于实现IFeedOperationsAND 的类,因此也是IOperationsWithPreInstalledData如此?

public class FeedsInstaller : IDependencyInstaller
{
    public void Install(IDependencyContainer container)
    {
        container.RegisterType(typeof(IFeedOperations), typeof(FeedOperations));
        container.RegisterType(typeof(IOperationsWithPreInstalledData), typeof(FeedOperations));
    }
}
Run Code Online (Sandbox Code Playgroud)

当前代码产生以下错误.如果我删除第二个RegisterType,那么当我打电话时,我得不到任何结果container.ResolveAll<IOperationsWithPreInstalledData>().

组件... Feeds.FeedOperations无法注册.已有一个具有该名称的组件.您想要修改现有组件吗?如果没有,请确保指定唯一名称.

如果我删除第二个RegisterType,那么当我打电话时,我得不到任何结果container.ResolveAll<IOperationsWithPreInstalledData>().Castle Windsor似乎没有看到实现的类IFeedOperations也实现了IOperationsWithPreInstalledData.

如何在Castle Windsor中注册我的实现类,以便它知道我的类实现了两个接口 - 或者说我的类可以解析任何一个接口.

Krz*_*mic 5

container.Register(Component.For<IFoo,IBar>().ImplementedBy<FooBar>());
Run Code Online (Sandbox Code Playgroud)