Exemple #1
0
        /// <summary>
        /// Handles messages of a given query type.
        /// </summary>
        /// <typeparam name="TQuery">A query type.</typeparam>
        /// <param name="handler">An handler.</param>
        /// <param name="channel">A channel.</param>
        /// <param name="topic">A topic.</param>
        /// <returns>A subscription.</returns>
        public static IDisposable HandleQuery <TQuery>(this IBox box, IHandler <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.AddHandler(handler, channel, topic));
        }