Skip to content

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

@ad0ran

Description

@ad0ran

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??

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions