温莎城堡-一类实现多个接口 [英] Castle Windsor - One class implementing multiple interfaces
问题描述
我在应用程序启动时注册了两个接口,如下所示:-
I register my two interfaces on application start as so:-
container.Register(Component.For(typeof(IEntityIndexController)).ImplementedBy(typeof(SnippetController)).LifeStyle.Transient);
container.Register(Component.For(typeof(ISnippetController)).ImplementedBy(typeof(SnippetController)).LifeStyle.Transient);
然后当我尝试运行IoC时,在使用第二个接口的对象上解析(ISnippetController ),它将引发以下异常:-
Then when I try to run an IoC.Resolve on an object that uses the second interface here (ISnippetController) it throws the following exception:-
无法创建组件'MyApp.Admin.Presenters.SnippetPresenter',因为它具有需要满足的依赖关系。
MyApp.Admin.Presenters.SnippetPresenter正在等待以下依赖项:
服务:
-未注册的MyApp.Admin.Controllers.ISnippetController。
如果我切换周围的注册顺序,则会抱怨它找不到IEntityIndexController。因此看来,它只选择了类的首次注册,然后忽略了映射到该具体类的所有其他接口。
If I switch the order of the registrations around it complains that it cannot find the IEntityIndexController. So it appears it only picks up the first registration of a class, then any further interfaces that map to that same concrete class are ignored.
失踪了吗? (使用.net 3.5的ps im,温莎RC3)
Is there something obvious here that I'm missing? (p.s. im using .net 3.5, windsor RC3)
推荐答案
您是否尝试过使用其他语法进行注册( AddComponent<>
)?
Have you tried registering with different syntax (AddComponent<>
)?
尝试更新到最新的主干版本,看看是否有帮助。在我看来像个虫子。
如果没有发生,请创建一个显示该错误的测试,然后在此处提交 a>
Try updating to latest trunk version and see if it helps. Looks like a bug to me. If it does not happen, create a test that exhibits the bug, and submit it here
这篇关于温莎城堡-一类实现多个接口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!