public void Add(string potName, Snapshot snapshot) { PotDirectory potDirectory = PotDirectory.FromPotName(potName); if (!potDirectory.IsValid) { throw new Exception($"There is no pot with name '{potName}'."); } SnapshotFile snapshotFile = potDirectory.CreateSnapshotFile(snapshot.CreationTime); snapshotFile.Open(); snapshotFile.Snapshot = snapshot.ToJSnapshot(); snapshotFile.Save(); }
public Snapshot GetByExactDateTime(string potName, DateTime dateTime) { PotDirectory potDirectory = PotDirectory.FromPotName(potName); if (!potDirectory.IsValid) { throw new Exception($"There is no pot with name '{potName}'."); } SnapshotFile snapshotFile = potDirectory.GetSnapshotFiles() .FirstOrDefault(x => x.CreationTime.HasValue && x.CreationTime.Value == dateTime); if (snapshotFile == null) { return(null); } snapshotFile.Open(); return(snapshotFile.Snapshot.ToSnapshot()); }
public Snapshot GetByIndex(string potName, int index = 0) { PotDirectory potDirectory = PotDirectory.FromPotName(potName); if (!potDirectory.IsValid) { throw new Exception($"There is no pot with name '{potName}'."); } SnapshotFile snapshotFile = potDirectory.GetSnapshotFiles() .Skip(index) .FirstOrDefault(); if (snapshotFile == null) { return(null); } snapshotFile.Open(); return(snapshotFile.Snapshot.ToSnapshot()); }