public virtual void Save() { if (_isDirty) { OperationAttempter.Attempt(() => SaveSettings(_path, _values)); } }
public Preferences(string path) { _path = path; OperationAttempter.Attempt(() => { var serializer = new XmlSerializer(typeof(SavedSettingsContainer)); using (var file = File.Open(_path, FileMode.Open)) { var toLoad = (SavedSettingsContainer)serializer.Deserialize(file); if (toLoad != null && toLoad.Settings != null) { foreach (var setting in toLoad.Settings) { _values[setting.Key] = setting.Value; } } } }); }