コード例 #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));
        }
コード例 #2
0
 public static void Flush <T>(this SnapshotHistory <T> history, ISnapshotWriter writer, string path)
     where T : Snapshot
 {
     for (int i = 0; i < history.Results.Count; i++)
     {
         writer.TrySave(history.Results[i], $"snapshot_{history.Results[i].Identifier}.json", path);
     }
 }
コード例 #3
0
 /// <summary>
 /// creates a new SnapshotClient
 /// </summary>
 /// <param name="snapshotReader"></param>
 /// <param name="snapshotWriter"></param>
 /// <param name="snapshotCompare"></param>
 public SnapshotClient(ISnapshotReader snapshotReader, ISnapshotWriter snapshotWriter, ISnapshotCompare snapshotCompare)
 {
     _snapshotReader  = snapshotReader;
     _snapshotWriter  = snapshotWriter;
     _snapshotCompare = snapshotCompare;
 }