public bool Match(IPersistedEvent @event) { if (@event.GetType() == typeof(TPersistedEvent)) { return(eventFilterFunction == null ? true : eventFilterFunction((TPersistedEvent)@event)); } return(false); }
public override bool ApplyEvent <TEvent>(IPersistedEvent @event) { if (this.Id != @event.AggregateRootId) { throw new Exception( $"Invalid event configuration. Cannot apply event with Aggregate Root id: {@event.AggregateRootId} on Aggregate Root id: {this.Id}"); } if (this.Version != @event.Version - 1) { throw new Exception( $"Invalid event configuration. Cannot apply event version: {@event.Version} on Aggregate Root version {this.Version}"); } if (!base.ApplyEvent <TEvent>(@event)) { throw new Exception( $"Aggregate {this.GetType().Name} does not provide a handler for event {@event.GetType().Name}"); } return(true); }