我有一个类在构造函数中接受一组接口:
public class Foo<T1,T2> : IFoo<T1,T2> { public Foo(IBar[] bars) { ... } }
我的容器注册如下:
container.Register(AllTypes.Pick().FromAssemblyNamed("...") .WithService.FirstInterface()); container.AddComponent("foo",typeof(IFoo<,>),typeof(Foo<,>));
我有几个实现的IBar,容器可以肯定地找到它们,因为调用ServiceLocator.Current.GetAllInstances< IBar>()工作正常.
但是,如果我尝试获得一个IFoo的实例,它会抛出一个异常,说它无法满足这个未被注册的“deoendency …”.
如果我更改构造函数以使单个IBar实例工作正常.
有任何想法吗?
添加ArrayResolver:
container.Kernel.Resolver.AddSubResolver(new ArrayResolver(container.Kernel));
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。