public async Task Dispatch(MessageContext messageContext, object message) { var type = message.GetType(); var handlers = handlerRegistry.GetHandlers(type); await Handle(messageContext, message, handlers); }
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; } } }
public void Dispatch(object message) { var type = message.GetType(); var handers = _registry.GetHandlers(type); foreach (var handler in handers) { handler.Execute(message, _serviceLocator); } }
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(); } }