/// <summary> /// Returns the profile associated with the key, or null if no such profile exists. /// </summary> /// <param name="key">The name of the registry key to define the profile under.</param> /// <returns></returns> public DestinationProfile loadProfile(String key) { SettingsPersisterHelper settings = getProfileSettings(key); if (settings.GetNames().Length == 0) { return(null); } DestinationProfile profile = new DestinationProfile(); profile.Id = key; profile.Name = settings.GetString(PROFILE_NAME_KEY, ""); profile.WebsiteURL = settings.GetString(PROFILE_WEBSITE_URL_KEY, ""); profile.FtpServer = settings.GetString(PROFILE_FTP_SERVER_KEY, ""); profile.UserName = settings.GetString(PROFILE_FTP_USER_KEY, ""); profile.FtpPublishPath = settings.GetString(PROFILE_FTP_PUBLISH_DIR_KEY, ""); profile.LocalPublishPath = settings.GetString(PROFILE_PUBLISH_DIR_KEY, ""); profile.Type = (DestinationProfile.DestType)settings.GetInt32(PROFILE_DESTINATION_TYPE_KEY, 0); //load the decrypted password try { profile.Password = settings.GetEncryptedString(PROFILE_FTP_PASSWORD_KEY); } catch (Exception e) { Trace.Fail("Failed to decrypt password: " + e); } return(profile); }
private void RestorePostListViewSettings() { IPostEditorPostSource postSource = listBoxPostSources.SelectedPostSource as IPostEditorPostSource; using (SettingsPersisterHelper postSourceSettings = _recentPostsSettings.GetSubSettings(postSource.UniqueId)) { // number of posts RecentPostRequest recentPostRequest = new RecentPostRequest(postSourceSettings.GetInt32(NUMBER_OF_POSTS, postSource.RecentPostCapabilities.DefaultRequest.NumberOfPosts)); if (comboBoxPosts.Items.Contains(recentPostRequest)) { comboBoxPosts.SelectedItem = recentPostRequest; } // pages if (postSource.SupportsPages) { radioButtonPages.Checked = postSourceSettings.GetBoolean(SHOW_PAGES, false); } else { radioButtonPages.Checked = false; } radioButtonPosts.Checked = !radioButtonPages.Checked; } }
private static void MaybeMigrateSettings() { try { int applicationSettingsVer = 1; SettingsPersisterHelper userSettings = ApplicationEnvironment.UserSettingsRoot; int currentSettingsVer = userSettings.GetInt32(SETTINGS_VERSION, 0); if (currentSettingsVer == 0) { userSettings.SetInt32(SETTINGS_VERSION, applicationSettingsVer); Trace.WriteLine("Migrating user settings..."); string legacyKeyName = @"Software\Open Live Writer"; SettingsPersisterHelper legacySettings = new SettingsPersisterHelper(new RegistrySettingsPersister(Registry.CurrentUser, legacyKeyName)); ApplicationEnvironment.UserSettingsRoot.CopyFrom(legacySettings, true, false); // Don't overwrite existing settings Registry.CurrentUser.DeleteSubKeyTree(legacyKeyName); } } catch (Exception ex) { Trace.Fail("Error while attempting to migrate settings.", ex.ToString()); } }