예제 #1
0
        public async Task Dispatch(MessageContext messageContext, object message)
        {
            var type     = message.GetType();
            var handlers = handlerRegistry.GetHandlers(type);

            await Handle(messageContext, message, handlers);
        }
예제 #2
0
        public async Task Invoke(IncomingLogicalContext context, IBusForHandler bus, Func <Task> next)
        {
            var messageType = context.LogicalMessage.Instance.GetType();

            var handlers = registry.GetHandlers(messageType);

            foreach (var handler in handlers)
            {
                var messageHandler = new MessageHandler
                {
                    Instance   = handler,
                    Invocation = (handlerInstance, message) => registry.InvokeHandle(handlerInstance, message, bus)
                };

                context.Handler = messageHandler;

                await next()
                .ConfigureAwait(false);

                if (context.HandlerInvocationAbortPending)
                {
                    break;
                }
            }
        }
예제 #3
0
        public void Dispatch(object message)
        {
            var type    = message.GetType();
            var handers = _registry.GetHandlers(type);

            foreach (var handler in handers)
            {
                handler.Execute(message, _serviceLocator);
            }
        }
예제 #4
0
        public async Task Dispatch(MessageContext messageContext, object message)
        {
            var handlers = handlerRegistry.GetHandlers(message.GetType());

            foreach (var h in handlers)
            {
                var handler = (IStaticHandler)serviceProvider.GetRequiredService(h.MethodInfo.DeclaringType);
                await handler.Handle(messageContext, message);

                await unitOfWork.Commit();
            }
        }