Esempio n. 1
0
        public static void ResolveFallbackMessageFactory(this IHasFallbackMessageFactory target, IEnumerable <Type> toResolveFrom = null)
        {
            if (toResolveFrom == null)
            {
                toResolveFrom = new AssemblyTypesEnumerator();
            }

            foreach (var type in toResolveFrom
                     .Where(cur => cur.GetCustomAttributes(typeof(FallbackMessageFactoryAttribute), false).Length >= 1))
            {
                target.FallbackFactory =
                    (IMessageParseFactory)type.GetConstructor(new Type[] {}).Invoke(new object[] {});
            }
        }
Esempio n. 2
0
        public static void RegisterMessagesInFallbackFactory(this IHasFallbackMessageFactory target,
                                                             IEnumerable <Type> toResolveFrom = null)
        {
            if (toResolveFrom == null)
            {
                toResolveFrom = new AssemblyTypesEnumerator();
            }

            foreach (var type in toResolveFrom)
            {
                if (type.GetCustomAttributes(typeof(RegisterMessageAttribute), false).Length > 0)
                {
                    target.FallbackFactory.RegisterMessageObjectFromAttribute(type);
                }
            }
        }