[英]Ninject generic type xml binding
I need to bind generic interface with generic implementation using Ninject.Extensions.Xml. 我需要使用Ninject.Extensions.Xml将通用接口与通用实现绑定。 The project is .net mvc project.
该项目是.net mvc项目。 Is there any way to accomplish this ?
有什么办法可以做到这一点?
The class: 班级:
public class JsonProvider<T> : IJsonProvider<T> where T: new()
{
...
}
Xml configuration (Not working): xml配置(不起作用):
<bind service="Base.IJsonProvider, Base" to="Base.JsonProvider, Base"
name ="Config"/>
You want to bind open generic types, so this type definition should do the trick: 您想绑定开放的泛型类型,因此此类型定义应能解决问题:
<bind service="Base.IJsonProvider`1, Base" to="Base.JsonProvider`1, Base"
name ="Config"/>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.