private static ControlSettings LoadSettings(IServiceProvider serviceProvider) { var store = GetWritableSettingsStore(serviceProvider); if (store.PropertyExists(SettingsCategoryName, SettingsPropertyName)) { var legacySerialized = new LegacyConfigurationSerializer <ControlSettings>(); string value = store.GetString(SettingsCategoryName, SettingsPropertyName); return(legacySerialized.Deserialize(value)); } return(new ControlSettings()); }
private static ControlSettings LoadSettings(IServiceProvider serviceProvider) { try { var store = GetWritableSettingsStore(serviceProvider); if (store.PropertyExists(settingsCategoryName, settingsPropertyName)) { var legacySerialized = new LegacyConfigurationSerializer <ControlSettings>(); var value = store.GetString(settingsCategoryName, settingsPropertyName); return(legacySerialized.Deserialize(value)); } } catch (Exception ex) { ex.Trace("Error when trying to load settings: " + ex.Message, System.Diagnostics.EventLogEntryType.Error); MessageBox.Show("An error occurred when trying to load current settings. To make sure everything is still working the settings are set to default."); } return(new ControlSettings()); }
private void LoadSettings() { try { if (_settingsStore.PropertyExists(settingsCategoryName, settingsPropertyName)) { var legacySerialized = new LegacyConfigurationSerializer <ControlSettings>(); var value = _settingsStore.GetString(settingsCategoryName, settingsPropertyName); Settings = legacySerialized.Deserialize(value); } else { Settings = new ControlSettings(); } DiagnosticsClient.ParticipateInTelemetry = Settings.GeneralSettings.ParticipateInTelemetry; } catch (Exception ex) { _logger.Error(ex, "Error when trying to load settings."); MessageBox.Show("An error occurred when trying to load current settings. To make sure everything is still working the settings are set to default."); } }