Ninject generic type xml binding

341 Views Asked by At

I need to bind generic interface with generic implementation using Ninject.Extensions.Xml. The project is .net mvc project. Is there any way to accomplish this ?

The class:

public class JsonProvider<T> : IJsonProvider<T> where T: new()
{
    ...
}

Xml configuration (Not working):

<bind service="Base.IJsonProvider, Base" to="Base.JsonProvider, Base"
   name ="Config"/>
1

There are 1 best solutions below

2
On BEST ANSWER

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"/>