Exemplo n.º 1
0
 public async virtual Task Handle(EventHandlerContext context, IEvent @event)
 {
     if (@event is TEvent)
     {
         await Handle(context, (TEvent)@event);
     }
 }
Exemplo n.º 2
0
        public async Task Notify(IServiceBus bus, ClaimsPrincipal user, IEvent @event)
        {
            Guard.AgainstNull(nameof(bus), bus);
            Guard.AgainstNull(nameof(user), user);
            Guard.AgainstNull(nameof(@event), @event);

            var context    = new EventHandlerContext(bus, user);
            var exceptions = new List <Exception>();

            foreach (var handler in handlers)
            {
                try
                {
                    await handler.Handle(context, @event);
                }
                catch (Exception ex)
                {
                    exceptions.Add(ex);
                }
            }

            if (exceptions.Count > 0)
            {
                throw new AggregateException(exceptions);
            }
        }
Exemplo n.º 3
0
 protected abstract Task Handle(EventHandlerContext context, TEvent @event);