public async Task <bool> SaveAsync() { Log.Debug($"[{Scope}] Saving snapshots"); var savingAsync = SavingAsync; if (savingAsync != null) { var cancelEventArgs = new CancelEventArgs(); await savingAsync(this, cancelEventArgs); if (cancelEventArgs.Cancel) { Log.Info("Saving canceled by SavingAsync event"); return(false); } } var snapshots = new List <ISnapshot>(); lock (_snapshots) { snapshots.AddRange(_snapshots); } await _snapshotStorageService.SaveSnapshotsAsync(snapshots); Saved.SafeInvoke(this); Log.Info($"[{Scope}] Saved '{snapshots.Count}' snapshots"); return(true); }
public void Save(string fileName = null) { fileName = GetFileName(fileName); Log.Info("Saving filter schemes to '{0}'", fileName); try { using (var stream = File.Open(fileName, FileMode.Create)) { _xmlSerializer.Serialize(FilterSchemes, stream, null); } Saved.SafeInvoke(this); Log.Debug("Saved filter schemes to '{0}'", fileName); } catch (Exception ex) { Log.Error(ex, "Failed to save filter schemes"); } }