protected override void OnExit(object sender, EventArgs e) { var app = Application as InstanceAwareApplication; if ((app != null && app.IsFirstInstance)) { _log.Info("Exiting application."); // make sure to save one final time the application wide settings. Properties.Settings.Default.Save(); var client = IoC.Get <IBigStashClient>(); if (client.IsLogged()) { _log.Info("Saving preferences.json at \"" + Properties.Settings.Default.SettingsFilePath + "\"."); // Reset the api endpoint to the default 'ServerBaseAddress' before saving the preferences file // for the last time. this.ResetDebugServerBaseAddress(client); // Save preferences file. LocalStorage.WriteJson(Properties.Settings.Default.SettingsFilePath, client.Settings, Encoding.UTF8, true); } if (Properties.Settings.Default.SettingsUpgradeRequired) { SquirrelHelper.CopyMigrationUserConfig(); } } base.OnExit(sender, e); }
/// <summary> /// Call SquirrelHelper.CopyMigrationUserConfig() to copy settings for migrating on the next run. /// </summary> /// <returns></returns> private string ConfigureSettingsMigration() { try { // Copy current user settings to migrate to. var migrationUserConfigPath = SquirrelHelper.CopyMigrationUserConfig(); return(migrationUserConfigPath); } catch (Exception) { _log.Error("Settings migration failed. Default settings will be used if the next instance is an update."); return(null); } }