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);
        }
Beispiel #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.");
        }
Beispiel #3
0
 /// <summary>
 /// Creates and returns a <see cref="Mailbox"/> for the given actor.
 /// </summary>
 /// <param name="cell">Cell of the actor.</param>
 /// <param name="mailboxType">The mailbox configurator.</param>
 /// <returns>The configured <see cref="Mailbox"/> for this actor.</returns>
 internal Mailbox CreateMailbox(ActorCell cell, MailboxType mailboxType)
 {
     return(new Mailbox(mailboxType.Create(cell.Self, cell.System)));
 }