使用IoC自动装配集合

时间:2010-04-17 08:20:10

标签: collections inversion-of-control autowired

任何人都知道是否存在可以处理此问题的IoC容器:

假设:

ISomeInterfce<T> where T : Entity

Impl1 : ISomeInterfce<Entity1>

Impl2 : ISomeInterfce<Entity1>

Impl3 : ISomeInterfce<Entity2>

Impl4 : ISomeInterfce<Entity2>

我希望能够自动连接我的系统并能够像这样解决

IoC.ResolveAll(typeof(ISomeInterfce<Entity1>)) 

然后收集回来 ISomeInterfce<Entity1>

的所有实现

1 个答案:

答案 0 :(得分:1)

Autofac(我最喜欢的IoC容器)支持此功能,请查看:http://code.google.com/p/autofac/wiki/Collections了解详情。