/// <summary>
        /// Saves a snapshot of the aggregate.
        /// </summary>
        public static async Task SaveSnapshot <TAggregate>(
            this ISnapshotRepository repository,
            TAggregate aggregate)
            where TAggregate : class, IEventSourced
        {
            var snapshotCreator = Configuration.Current.Container.Resolve <ICreateSnapshot <TAggregate> >();

            var snapshot = snapshotCreator.CreateSnapshot(aggregate);

            aggregate.InitializeSnapshot(snapshot);

            await repository.SaveSnapshot(snapshot);
        }
Пример #2
0
        /// <summary>
        /// Saves a snapshot of the aggregate.
        /// </summary>
        public static async Task SaveSnapshot <TAggregate>(
            this ISnapshotRepository repository,
            TAggregate aggregate)
            where TAggregate : class, IEventSourced
        {
            var snapshotCreator = Configuration.Current.Container.Resolve <ICreateSnapshot <TAggregate> >();

            var snapshot = snapshotCreator.CreateSnapshot(aggregate);

            snapshot.AggregateId       = aggregate.Id;
            snapshot.AggregateTypeName = AggregateType <TAggregate> .EventStreamName;
            snapshot.LastUpdated       = Clock.Now();
            snapshot.Version           = aggregate.Version;
            snapshot.ETags             = aggregate.ETags()
                                         .Where(e => !string.IsNullOrWhiteSpace(e))
                                         .ToArray();

            await repository.SaveSnapshot(snapshot);
        }
Пример #3
0
 /// <summary>
 /// Saves a snapshot of the aggregate.
 /// </summary>
 public static async Task SaveSnapshot <TAggregate>(
     this ISnapshotRepository repository,
     TAggregate aggregate)
     where TAggregate : class, IEventSourced =>
 await repository.SaveSnapshot(aggregate.CreateSnapshot());