예제 #1
0
        /// <summary>
        /// Handles messages of a given query type asynchronously.
        /// </summary>
        /// <typeparam name="TQuery">A query type.</typeparam>
        /// <param name="handler">An asynchronous handler.</param>
        /// <param name="channel">A channel.</param>
        /// <param name="topic">A topic.</param>
        /// <returns>A subscription.</returns>
        public static IDisposable HandleQueryAsync <TQuery>(this IBox box, IAsyncHandler <TQuery> handler, string channel = null, string topic = null) where TQuery : IQuery
        {
            if (topic == null)
            {
                throw new ArgumentNullException(nameof(topic));
            }

            if (handler == null)
            {
                throw new ArgumentNullException(nameof(handler));
            }

            return(box.AddAsyncHandler(handler, channel, topic));
        }