Using Ninject 3.0.0-rc3, you can use
kernel.Bind( x => x.FromThisAssembly() .SelectAllClasses().InheritedFrom(typeof(BaseService<>)).WhichAreGeneric() .BindToAllInterfaces());
Depending on your requirements, you can remove the WhichAreGeneric operator. .SelectAllClasses().InheritedFrom(typeof(BaseService<>)).WhichAreGeneric() selects the classes for which the binding is being created.
Conventions ensure that the interface and implementation class must have the same open type arguments. For instance. When
interface IBar<T1, T2> interface IBaz<T> interface IFoo class Bar<T1, T2> : IBar<T1, T2>, IBaz<T1>, IFoo class Foo : IBar<int, int>, IFoo
IBar<T1, T2> is the only valid interface for Bar<T1, T2> . But for Foo, both IBar<int, int>, IFoo valid.
source share