lundi 29 août 2016

C# find generic Interface implemented classes and create objects

I have a message handler class.

public interface IMessageHandler<in TMessage> where TMessage: IMessage
{
    void Handle(TMessage message);
}

And I want to select all classes that implements IMessageHandler<> interface and create instance of that class. Then I will call the handle method.





Aucun commentaire:

Enregistrer un commentaire