Пример #1
0
        public void Handle <TMessage>(TMessage message) where TMessage : Message
        {
            var handlers = _handlerFactory.GetHandlersFor <TMessage>();

            foreach (var handler in handlers)
            {
                handler.HandleMessage(message);
            }
        }
Пример #2
0
        public void DispatchEvent(Event @event)
        {
            IEnumerable <dynamic> eventHandlers = factory.GetHandlersFor(@event);

            if (eventHandlers != null && eventHandlers.Any())
            {
                Parallel.ForEach(eventHandlers, handler => handler.Handle((dynamic)@event));
            }
        }