Esempio n. 1
0
        public IEnumerable <IMessageInterfaceType> GetMessageTypes()
        {
            if (typeof(T).IsGenericType && typeof(T).GetGenericTypeDefinition() == typeof(IHandler <>))
            {
                var interfaceType = new CustomConsumerInterfaceType(typeof(T).GetGenericArguments()[0], typeof(T));
                if (interfaceType.MessageType.IsValueType == false && interfaceType.MessageType != typeof(string))
                {
                    yield return(interfaceType);
                }
            }

            IEnumerable <CustomConsumerInterfaceType> types = typeof(T).GetInterfaces()
                                                              .Where(x => x.IsGenericType)
                                                              .Where(x => x.GetGenericTypeDefinition() == typeof(IHandler <>))
                                                              .Select(x => new CustomConsumerInterfaceType(x.GetGenericArguments()[0], typeof(T)))
                                                              .Where(x => x.MessageType.IsValueType == false && x.MessageType != typeof(string));

            foreach (CustomConsumerInterfaceType type in types)
            {
                yield return(type);
            }
        }
        public IEnumerable <IMessageInterfaceType> GetMessageTypes()
        {
            var typeInfo = typeof(T).GetTypeInfo();

            if (typeInfo.IsGenericType && typeInfo.GetGenericTypeDefinition() == typeof(IHandler <>))
            {
                var interfaceType = new CustomConsumerInterfaceType(typeInfo.GetGenericArguments()[0], typeof(T));
                if (TypeMetadataCache.IsValidMessageType(interfaceType.MessageType))
                {
                    yield return(interfaceType);
                }
            }

            IEnumerable <CustomConsumerInterfaceType> types = typeof(T).GetInterfaces()
                                                              .Where(x => x.GetTypeInfo().IsGenericType)
                                                              .Where(x => x.GetTypeInfo().GetGenericTypeDefinition() == typeof(IHandler <>))
                                                              .Select(x => new CustomConsumerInterfaceType(x.GetTypeInfo().GetGenericArguments()[0], typeof(T)))
                                                              .Where(x => TypeMetadataCache.IsValidMessageType(x.MessageType));

            foreach (CustomConsumerInterfaceType type in types)
            {
                yield return(type);
            }
        }