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