Пример #1
0
 public async virtual Task Handle(EventHandlerContext context, IEvent @event)
 {
     if (@event is TEvent)
     {
         await Handle(context, (TEvent)@event);
     }
 }
Пример #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);
            }
        }
Пример #3
0
 protected abstract Task Handle(EventHandlerContext context, TEvent @event);