public void Save() { var serializer = new JsonApplicationSettingSerializer(); var content = serializer.Save(_data); try { System.IO.File.WriteAllText(_settingFilePath.Value, content.Value); } catch (Exception) { // if settings cannot be saved, we cannot do anything but reset the settings _data = new ApplicationSettingsDataMixin(); } }
public void Load(string applicationSettingsPath) { var settingsFile = new FileName(applicationSettingsPath); _settingFilePath = settingsFile; // return default settings in case // file could not be loaded if (!settingsFile.IsValid) return; try { var content = System.IO.File.ReadAllText(settingsFile.Value); var settings = new JsonApplicationSettingSerializer().Load(new JsonContent(content)); // reset the newly loaded settings _data = settings; } catch (Exception) { // we could not load the settings, so return // default settings _data = new ApplicationSettingsDataMixin(_settingFilePath.Value); } }
public ApplicationSettings() { _data = new ApplicationSettingsDataMixin(); }