コード例 #1
0
ファイル: SnapperCore.cs プロジェクト: zubivan/Snapper
        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));
        }