/// <summary> /// 1) If file exists it is renamed to file.delete /// 2) The contents of <paramref name="stream"/> is saved to tempFile /// 3.a 1) On success tempfile is renamed to <paramref name="file"/> /// 2.a) If backup file.delete is renamed to backup name. /// 2.b) If no backup file.delete is deleted /// 3.b 1) file.delete is renamed back to file /// 2) tempfile is deleted /// </summary> protected void SaveStreamCore(FileInfo file, FileInfo tempFile, Stream stream) { using (var transaction = new SaveTransaction(file, tempFile, stream, this.Backuper)) { transaction.Commit(this.serialize, this.Settings); } }
/// <summary> /// Caches and tracks if needed. /// Then serializes and saves. /// </summary> protected void SaveCore <T>(FileInfo file, FileInfo tempFile, T item) { this.CacheAndTrackCore(file, item); using (var transaction = new SaveTransaction(file, tempFile, item, this.Backuper)) { transaction.Commit(this.serialize, this.Settings); } }