Пример #1
0
 /// <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);
     }
 }
Пример #2
0
 /// <summary>
 /// Save <paramref name="stream"/> to <paramref name="tempFile"/> then rename it to <paramref name="file"/>.
 /// Uses a <see cref="SaveTransaction"/>
 /// </summary>
 protected async Task SaveStreamCoreAsync(FileInfo file, FileInfo tempFile, Stream stream)
 {
     using (var saveTransaction = new SaveTransaction(file, tempFile, stream, this.Backuper))
     {
         await saveTransaction.CommitAsync()
         .ConfigureAwait(false);
     }
 }
Пример #3
0
 /// <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);
     }
 }