예제 #1
0
        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));
        }
예제 #2
0
파일: SnapperCore.cs 프로젝트: urig/Snapper
        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));
        }