public interface IFeedOperations : IOperationsWithPreInstalledData
{
...
}
public class FeedOperations : IFeedOperations
{
}
如何使用RegisterType为实现IFeedOperations
因此IOperationsWithPreInstalledData
还有一类?
public class FeedsInstaller : IDependencyInstaller
{
public void Install(IDependencyContainer container)
{
container.RegisterType(typeof(IFeedOperations), typeof(FeedOperations));
container.RegisterType(typeof(IOperationsWithPreInstalledData), typeof(FeedOperations));
}
}
当前的代码产生以下错误。如果我删除第二个RegisterType,那么当我拨打container.ResolveAll<IOperationsWithPreInstalledData>()
时,我将得不到结果。
Component ... Feeds.FeedOperations不能被 注册。已经有一个名称的组件。您是否想要 修改现有组件?如果没有,请确保您 指定了一个唯一的名称。
如果我删除第二个RegisterType,那么当我拨打container.ResolveAll<IOperationsWithPreInstalledData>()
时,我将得不到结果。温莎城堡似乎没有看到实施IFeedOperations
的课程也实施了IOperationsWithPreInstalledData
。
如何在Castle Windsor注册我的实现类,以便它知道我的类实现了两个接口 - 或者说我的类可以解决任一接口。
您是否在意创建两个类的实例(每个接口一个)? – svick
宁愿只举一个例子,但在这种情况下我不挑剔。 – kingdango
另外,'IDependencyContainer'似乎不是来自Castle的任何类型。这是您的自定义界面吗? – svick