Ejemplo n.º 1
0
        public async Task PublishAsync <TEvent>(TEvent @event) where TEvent : IEvent
        {
            var handlers        = _handlerResolver.ResolveEventHandlers <IEventHandler <TEvent> >();
            var orderedHandlers = _handlerResolver.ResolveEventHandlers <ISequenceEventHandler <TEvent> >()
                                  .OrderBy(x => x.Order);

            foreach (var handler in orderedHandlers)
            {
                await handler.HandleAsync(@event);
            }
            foreach (var handler in handlers)
            {
                await handler.HandleAsync(@event);
            }
        }