示例#1
0
 private void TryCreateCreateSnapshot(AggregateRoot savedInstance)
 {
     if (_snapshottingPolicy.ShouldCreateSnapshot(savedInstance))
     {
         var snapshot = _domainRepository.TryTakeSnapshot(savedInstance);
         if (snapshot != null)
         {
             _snapshotStore.SaveShapshot(snapshot);
         }
     }
 }
示例#2
0
        public void Save(AggregateRoot aggregateRoot)
        {
            var events = aggregateRoot.GetUncommittedEvents();

            _store.Save(aggregateRoot);
            _eventBus.Publish(events);
            // TODO: Snapshot should not effect saving.
            if (ShouldCreateSnapshot(aggregateRoot))
            {
                var snapshot = GetSnapshot(aggregateRoot);

                if (snapshot != null)
                {
                    _snapshotStore.SaveShapshot(snapshot);
                }
            }
            aggregateRoot.AcceptChanges();
        }