/// <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)); }
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); } }