public static Task SaveEvents <T>( this ISqlEventStore eventStore, IEnumerable <IDomainEvent> events) where T : class, IEventSourced { if (eventStore == null) { throw new ArgumentNullException(nameof(eventStore)); } return(eventStore.SaveEvents <T>(events, null, CancellationToken.None)); }
private Task SaveEvents( T source, string operationId, Guid?correlationId, string contributor, CancellationToken cancellationToken) { return(_eventStore.SaveEvents <T>( source.FlushPendingEvents(), operationId, correlationId, contributor, cancellationToken)); }
private async Task SaveSource( T source, Guid?correlationId, CancellationToken cancellationToken) { await _eventStore.SaveEvents <T>(source.PendingEvents, correlationId, cancellationToken).ConfigureAwait(false); await _eventPublisher.PublishPendingEvents(source.Id, cancellationToken).ConfigureAwait(false); if (_mementoStore != null) { if (source is IMementoOriginator mementoOriginator) { IMemento memento = mementoOriginator.SaveToMemento(); await _mementoStore.Save <T>(source.Id, memento, cancellationToken).ConfigureAwait(false); } } }