ninject / Ninject.Extensions.Conventions

Convention based binding for Ninject
Other
76 stars 28 forks source link

Binding types that have multiple generic interfaces of the same type #29

Open ad0ran opened 7 years ago

ad0ran commented 7 years ago

So say I have a type that implements interfaces like this:

public class MessageHandler : IHandle<MessageOne>, IHandle<MessageTwo>, IHandle<MessageThree> {
    ...
}

Binding with conventions doesn't seem to work when

IKernel container = new StandardKernel();
container.Bind(x =>
    x.FromAssemblyContaining<MessageHandler>()
        .SelectAllClasses()
        .InheritedFrom(typeof(IHandle<>))
        .BindToSelf())
);

var handlers = container.GetAll(typeof(IHandle<MessageOne>)); // handlers is just empty after trying to get the services

Is the open generic not supported??