public void Handle <TMessage>(TMessage message) where TMessage : Message { var handlers = _handlerFactory.GetHandlersFor <TMessage>(); foreach (var handler in handlers) { handler.HandleMessage(message); } }
public void DispatchEvent(Event @event) { IEnumerable <dynamic> eventHandlers = factory.GetHandlersFor(@event); if (eventHandlers != null && eventHandlers.Any()) { Parallel.ForEach(eventHandlers, handler => handler.Handle((dynamic)@event)); } }