简体   繁体   English

Castle Windsor-开放通用接口的IoC注册?

[英]Castle Windsor - IoC registration for open generic interfaces?

Does Castle Windsor permit registration of an open generic interface or do I need to register each possible typed instance separately? 温莎城堡是否允许注册开放的通用接口,或者我需要分别注册每个可能的类型化实例?

Example - the below with types T,Z fails upon compilation unless I separately specify T, Z with strong types. 示例-以下类型为T,Z的代码在编译时会失败,除非我分别使用强类型指定T,Z。

 container.Register(Component
      .For<IAdapterFactory<T,Z>>()
      .ImplementedBy<AdapterFactory<T,Z>>()
      .LifeStyle.PerWebRequest);

It's called open generic , and yes, Windsor does support that. 这被称为开放通用 ,是的,温莎确实支持。

 container.Register(Component
             .For(typeof(IAdapterFactory<,>))
             .ImplementedBy(typeof(AdapterFactory<,>))
             .LifestylePerWebRequest());

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM