private void TryCreateCreateSnapshot(AggregateRoot savedInstance) { if (_snapshottingPolicy.ShouldCreateSnapshot(savedInstance)) { var snapshot = _domainRepository.TryTakeSnapshot(savedInstance); if (snapshot != null) { _snapshotStore.SaveShapshot(snapshot); } } }
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(); }