2011-06-22 66 views
0

进出口新的Autofac和发现自己重复了很多这....Autofac约定泛型类型

builder.RegisterType<ConcreteService<EntityA>>().As<IService<EntityA>>(); 
builder.RegisterType<ConcreteService<EntityB>>().As<IService<EntityB>>(); 

EntityAEntityBEntityC等..所有从EntityBase继承,所以我想指示Autofac始终使用ConcreteService<x>时,它需要只要从x EntityBase

我知道,在Autofac的AssemblyScanner可能能够帮助这个继承创建的IService<x>的实现,虽然我努力寻找文档这远远不够。

任何指针赞赏。

+0

[解决通用接口与Autofac](http://stackoverflow.com/questions/1189519/resolving-generic-interface-with-autofac) – Steven

回答