samedi 28 mars 2015

Find implemented types from Generic interface in c#


public class AccountCreatedEvent : EventBase{}

public class AccountHandler : IEventHandler<AccountCreatedEvent>
{
public void Handle(AccountCreatedEvent event)
{
}
}


This is a handler class and I want to get this class with c# code. I want to get list of implemented classes from IEventHandler type.



public class Account
{
public void OnAccountCreated(EventBase accountCreatedEvent)
{
var handler = typeof(IEventHandler<>);
var events = AppDomain.CurrentDomain.GetAssemblies()
.SelectMany(s => s.GetTypes())
.Where(p => denormalizer.IsAssignableFrom(p) && denormalizer.IsGenericType);

}
}


But var events is returning



{Name = "IEventHandler`1" FullName = "Project1.IEventHandler`1"}





Aucun commentaire:

Enregistrer un commentaire