I am using .NET 4.5, Ninject 3 with the binding by convention lib as follow:
kernel.Bind(x => x
.FromAssembliesMatching("assembly.dll")
.SelectAllClasses().InheritedFrom(typeof(ICommandHandler<>))
.BindAllInterfaces());
And this is binding properly for:
public class MyCommandHandler : ICommandHandler<MyCommand>
But doesn't bind:
public class MyGenericCommandHandler<T> : ICommandHandler<MyGenericCommand<T>>
However, the previous binding works if I add individual bindings for specific implementation of my generics class, such as:
kernel.Bind(typeof(ICommandHandler<MyGenericCommand<float>>))
.To(typeof(MyGenericCommandHandler<float>))
kernel.Bind(typeof(ICommandHandler<MyGenericCommand<int>>))
.To(typeof(MyGenericCommandHandler<int>))
But adding each individual generic type defeats the purpose of conventions and require adding binding for each possible individual type such as float, int, string, etc...
Do you know how to modify the convention or add another one (or even come with a completely different solution) to support the generic version of my command? i.e. supporting two-level generics.