[英]NInject. Register generic types
Please explain how to bind a generic type to its implementer if that implementer is also a generic class, for example, IRepository<T>
and EfRepository<T>
. 如果该实现者也是泛型类,例如IRepository<T>
和EfRepository<T>
,请说明该泛型类型如何与其实现者绑定。 I need just one action to register this binding 我只需执行一个操作即可注册此绑定
您只需要使用接受类型参数的重载,而忽略通用参数。
kernel.Bind(typeof(IRepository<>)).To(typeof(EfRepository<>));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.