Exemple #1
0
        static MessageTypeMapper()
        {
            var assemblyList = AppDomain.CurrentDomain.GetAssemblies().Where(a => !a.IsDynamic);
            var eventType    = typeof(IMessage);

            foreach (var assembly in assemblyList)
            {
                var allType = assembly.GetExportedTypes().Where(t => eventType.IsAssignableFrom(t));
                foreach (var type in allType)
                {
                    EventTypeDict.Add(type.FullName, type);
                }
            }
        }
Exemple #2
0
        static MessageTypeMapper()
        {
            var assemblyList = AppDomain.CurrentDomain.GetAssemblies().Where(a => !a.IsDynamic);
            var eventType    = typeof(IMessage);

            foreach (var assembly in assemblyList)
            {
                var allType = assembly.GetExportedTypes().Where(t => eventType.IsAssignableFrom(t) && t.IsClass && t.GetConstructors().Any(c => c.GetParameters().Length == 0));
                foreach (var type in allType)
                {
                    if (Activator.CreateInstance(type) is IMessage msg)
                    {
                        EventTypeDict.Add(type.FullName, type);
                    }
                }
            }
        }