public static Task SaveEvents <T>(
            this IAzureEventStore 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));
 }
Exemplo n.º 3
0
        private async Task SaveAndPublish(
            T source, Guid?correlationId, CancellationToken cancellationToken)
        {
            await _eventStore.SaveEvents <T>(source.PendingEvents, correlationId, cancellationToken).ConfigureAwait(false);

            await _eventPublisher.PublishPendingEvents <T>(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);
                }
            }
        }