private static void AddItem(IDictionary<Type, IList<Type>> dictionary, Type type)
{
var theEvent = type.GetInterfaces()
.Where(x => x.IsGenericType && x.GetGenericTypeDefinition() == typeof(HandlesEvent<>))
.First()
.GetGenericArguments()
.First();
if (!dictionary.ContainsKey(theEvent))
dictionary.Add(theEvent, new List<Type>());
dictionary[theEvent].Add(type);
}