我想用温莎城堡解决以下问题:
IEnumerable<Definition<IEntity>>
目前我只得到一个带有 1 个对象的 IEnumerable,它与 IEntity 的第一个实现相匹配。
我想要一个数组
{ Definition<Entity1>, Definition<Entity2>, ... }
我觉得需要一个子解析器,但我不知道从哪里开始。
更新
var container = new WindsorContainer();
container.Kernel.Resolver.AddSubResolver(
new CollectionResolver(container.Kernel, true));
container.Register(Component.For(typeof (Definition<>)));
var binDir = HostingEnvironment.MapPath("~/bin");
var assemblyFilter = new AssemblyFilter(binDir);
container.Register(Types.FromAssemblyInDirectory(assemblyFilter)
.BasedOn<IEntity>()
.Unless(t => t.IsAbstract || t.IsInterface)
.WithServiceAllInterfaces()
.LifestyleTransient());
// This doesn't work!
var items = container.Resolve(typeof(IEnumerable<Definition<IEntity>>));