CQRSSample.Infrastructure.Installers.EventHandlerHelper.AddItem C# (CSharp) Method

AddItem() private static method

private static AddItem ( IDictionary dictionary, Type type ) : void
dictionary IDictionary
type System.Type
return void
        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);
        }