Exemplo n.º 1
0
        private Type GetProducedMessageQueueType(MailboxType mailboxType)
        {
            var queueType = mailboxType.GetType().GetTypeInfo().GetInterfaces()
                            .Where(i => i.GetTypeInfo().IsGenericType)
                            .Where(i => i.GetGenericTypeDefinition() == ProducesMessageQueueGenericType)
                            .Select(i => i.GetTypeInfo().GetGenericArguments().First())
                            .FirstOrDefault();

            if (queueType == null)
            {
                throw new ArgumentException(nameof(mailboxType), $"No IProducesMessageQueue<TQueue> supplied for {mailboxType}; illegal mailbox type definition.");
            }
            return(queueType);
        }
Exemplo n.º 2
0
        private Type GetProducedMessageQueueType(MailboxType mailboxType)
        {
            var interfaces = mailboxType.GetType().GetTypeInfo().GetInterfaces();

            for (int i = 0; i < interfaces.Length; i++)
            {
                var element = interfaces[i];
                if (element.GetTypeInfo().IsGenericType&& element.GetGenericTypeDefinition() == ProducesMessageQueueGenericType)
                {
                    return(element.GetGenericArguments()[0]);
                }
            }

            throw new ArgumentException(nameof(mailboxType), $"No IProducesMessageQueue<TQueue> supplied for {mailboxType}; illegal mailbox type definition.");
        }