private static void HandleDomainEvent(IDomainEventHandlerContext context, IDomainEventHandlerCollection handlers) { Contract.Requires(handlers != null); Contract.Requires(context != null); var exceptions = new Collection <Exception>(); foreach (var handler in handlers) { Contract.Assume(handler != null); try { HandleDomainEvent(context, handler); } catch (DomainEventHandlingException exception) { exceptions.Add(exception); } } if (exceptions.Count > 1) { // re-throw exceptions as an aggregate throw new AggregateException("One or more domain event handling exceptions occurred.", exceptions); } }
public override void Handle(IDomainEventHandlerContext <CreditApplied> context) { var domainEvent = context.DomainEvent; Console.WriteLine(string.Format("Credit applied for Account {0} with amount {1:$0.00} setting current balance to {2:$0000.00}", domainEvent.AccountId, domainEvent.Amount)); }
public void Handle(IDomainEventHandlerContext context) { var genericContext = context as IDomainEventHandlerContext <TDomainEvent>; if (genericContext == null) { Handle(new DomainEventHandlerContext <TDomainEvent>(context)); } else { Handle(genericContext); } }
private static void HandleDomainEvent(IDomainEventHandlerContext context, IDomainEventHandler handler) { Contract.Requires(handler != null); Contract.Requires(context != null); try { // handle command handler.Handle(context); } catch (Exception e) { // re-throw exception as a domain event handling exception throw new DomainEventHandlingException(context.DomainEvent, e, "Exception occurred in domain event handler, check inner exception for details."); } }
public abstract void Handle(IDomainEventHandlerContext <TDomainEvent> context);
public override void Handle(IDomainEventHandlerContext <TDomainEvent> context) { }
public override void Handle(IDomainEventHandlerContext <TDomainEvent> context) { _action(context.DomainEvent); }
public void Handle(IDomainEventHandlerContext context) { Contract.Requires(context != null); }
public override void Handle(IDomainEventHandlerContext <TDomainEvent> context) { Handle((IProjectionHandlerContext <TProjection, TDomainEvent>)context); }
public DomainEventHandlerContext(IDomainEventHandlerContext context) : this((TDomainEvent)context.DomainEvent, context.Metadata) { Contract.Requires(context != null); }