private async Task TryMakeSnapshot(AggregateRoot aggregate)
        {
            if (!await _snapshotStrategy.ShouldMakeSnapShot(aggregate).ConfigureAwait(false))
            {
                return;
            }

            dynamic snapshot = aggregate.Invoke("GetSnapshot");

            snapshot.Version = aggregate.Version + aggregate.GetUncommittedChanges().Length;
            await _snapshotStore.SaveAsync(snapshot).ConfigureAwait(false);
        }
Exemplo n.º 2
0
 /// <summary>
 /// 保存快照
 /// </summary>
 /// <param name="snapshot">要保存的快照对象</param>
 public static void Save(this ISnapshotStore snapshotStore, Snapshot snapshot)
 {
     snapshotStore.SaveAsync(snapshot)
     .Wait();
 }