示例#1
0
        /// <summary>
        /// Configure message handler
        /// </summary>
        /// <param name="messageType">Message type</param>
        /// <param name="func">Func</param>
        public static void ConfigureMessageHandler(string messageType, Func <SendMessageContext, Task <SendMessageResult> > func)
        {
            if (func == null)
            {
                return;
            }
            DefaultMessageHandler defaultMessageHandler = new DefaultMessageHandler(func);

            ConfigureMessageHandler(messageType, defaultMessageHandler);
        }
示例#2
0
        /// <summary>
        /// Configure message handler
        /// </summary>
        /// <param name="messageType">Message type</param>
        /// <param name="func">Func</param>
        public static void ConfigureMessageHandler(string messageType, Func <SendMessageContext, SendMessageResult> func)
        {
            if (func == null)
            {
                return;
            }
            Task <SendMessageResult> asyncFunc(SendMessageContext context) => Task.Run(() =>
            {
                return(func(context));
            });

            DefaultMessageHandler defaultMessageHandler = new DefaultMessageHandler(asyncFunc);

            ConfigureMessageHandler(messageType, defaultMessageHandler);
        }