public List<Type> GetHandledEvents()
{
var handledEvents = new HashSet<Type>();
var assemblies = GetAssemblies();
foreach (var assembly in assemblies)
{
foreach (var type in assembly.GetTypes())
{
if (type.IsInterface || type.IsAbstract)
continue;
var commandHandlingInterfaces =
type.GetInterfaces().Where(x => x.IsGenericType && x.GetGenericTypeDefinition() == typeof(IBusEventHandler<>));
foreach (var commandHandlingInterface in commandHandlingInterfaces)
{
handledEvents.Add(commandHandlingInterface.GetGenericArguments()[0]);
}
}
}
return handledEvents.ToList();
}