Beispiel #1
0
        /// <summary>
        /// Attempts to save the <see cref="SnapshotResult{T}"/> to disk.
        /// </summary>
        /// <param name="result"></param>
        /// <param name="writer"></param>
        /// <param name="file"></param>
        /// <param name="path"></param>
        /// <typeparam name="T"></typeparam>
        /// <exception cref="ArgumentNullException"></exception>
        public static bool Save <T>(this SnapshotResult <T> result, ISnapshotWriter writer, string file, string path)
            where T : Snapshot
        {
            if (string.IsNullOrWhiteSpace(file))
            {
                throw new ArgumentNullException(nameof(file));
            }

            if (string.IsNullOrWhiteSpace(path))
            {
                throw new ArgumentNullException(nameof(path));
            }

            if (writer.IsNull())
            {
                throw new ArgumentNullException(nameof(writer));
            }

            if (result.IsNull())
            {
                throw new ArgumentNullException(nameof(result));
            }

            return(writer.TrySave(result, file, path));
        }
Beispiel #2
0
        public void OnSuccess(SnapshotResult snapshotResult)
        {
            var msg = "snapshot operation success. \n";

            msg += string.Format("id: {0}, description:{1}", snapshotResult.Snapshot.SnapshotData.SnapshotId,
                                 snapshotResult.Snapshot.SnapshotData.Description);
            Show(msg);
        }
Beispiel #3
0
        /// <summary>
        /// validates the snapshot against the saved snapshot
        /// </summary>
        /// <param name="setup"></param>
        /// <param name="snapshot"></param>
        /// <param name="options"></param>
        /// <returns></returns>
        public SnapshotResult Validate(Snapshot snapshot, SnapshotSetup setup, SnapshotOptions options)
        {
            if (setup.UpdateSnapshot || options.UpdateSnapshot)
            {
                return(SnapshotResult.UpdateSnapshot(snapshot));
            }

            var snapshots  = Read(setup);
            var savedToken = snapshots?.GetSnapshot(snapshot.Metadata);

            return(_snapshotCompare.Compare(snapshot, savedToken, options));
        }
Beispiel #4
0
        protected virtual bool Write <T>(SnapshotResult <T> result, string file, string path)
            where T : Snapshot
        {
            string fullPath = $"{path}/{file}";

            if (File.Exists(fullPath))
            {
                return(false);
            }

            File.WriteAllText(fullPath, result.ToJsonString());
            return(true);
        }
Beispiel #5
0
        public bool TrySave <T>(SnapshotResult <T> result, string file, string path)
            where T : Snapshot
        {
            if (DirectoryExists(path))
            {
                return(Write(result, file, path));
            }

            if (CreateDirectory(path))
            {
                return(Write(result, file, path));
            }

            return(false);
        }
 public void Purge <U>(SnapshotResult <U> result) where U : Snapshot
 {
     throw new NotImplementedException();
 }
Beispiel #7
0
 public void Purge <U>(SnapshotResult <U> result)
     where U : Snapshot => _snapshots.Remove(result.Identifier);
Beispiel #8
0
 public void Purge <U>(SnapshotResult <U> result)
     where U : Snapshot
 {
 }