我是新來的溫莎城堡。Castle Windsor:自動註冊每個類型的其他程序集
在一個總成,Domain.Classes
class BaseEntity
{
}
class Entity1 : BaseEntity {}
class Entity2 : BaseEntity {}
class Entity3 : BaseEntity {}
在另一個組件,我有接口,
class GenericImplementation <BaseEntity>: IGenerticInterface<BaseEntity>
{
// base on BaseEntity
// does something
}
如何註冊GenericImplementation爲每BaseEntity(ENTITY1,ENTITY2,ENTITY3等)在程序集中給出Domain.Classes?
我試過這種方式,但沒有工作。
container.Register(Classes.FromAssemblyNamed("Domain.Classes")
.BasedOn(typeof(IGenerticInterface<>))
.Configure(c => c.ImplementedBy(typeof (GenericImplementation<>)))
.LifestyleTransient());
[Castle Windsor - 開放式通用接口的IoC註冊?]的可能重複?(http://stackoverflow.com/questions/12344708/castle-windsor-ioc-registration-for-open-generic-interfaces) –