protected SnapResult Snap(SnapshotId snapshotId, object newSnapshot) { var currentSnapshot = _snapshotStore.GetSnapshot(snapshotId); if (ShouldUpdateSnapshot(currentSnapshot, newSnapshot)) { _snapshotStore.StoreSnapshot(snapshotId, newSnapshot); return(SnapResult.SnapshotUpdated(currentSnapshot, newSnapshot)); } if (currentSnapshot == null) { return(SnapResult.SnapshotDoesNotExist(newSnapshot)); } return(_snapshotComparer.CompareSnapshots(currentSnapshot, newSnapshot) ? SnapResult.SnapshotsMatch(currentSnapshot, newSnapshot) : SnapResult.SnapshotsDoNotMatch(currentSnapshot, newSnapshot)); }
protected SnapResult Snap(SnapshotId snapshotId, object newSnapshot) { var currentSnapshot = _snapshotStore.GetSnapshot(snapshotId); var areSnapshotsEqual = currentSnapshot != null && _snapshotComparer.CompareSnapshots(currentSnapshot, newSnapshot); if (!areSnapshotsEqual && _snapshotUpdateDecider.ShouldUpdateSnapshot()) { _snapshotStore.StoreSnapshot(snapshotId, newSnapshot); return(SnapResult.SnapshotUpdated(currentSnapshot, newSnapshot)); } if (currentSnapshot == null) { return(SnapResult.SnapshotDoesNotExist(newSnapshot)); } return(areSnapshotsEqual ? SnapResult.SnapshotsMatch(currentSnapshot, newSnapshot) : SnapResult.SnapshotsDoNotMatch(currentSnapshot, newSnapshot)); }