static WebProxySettings()
        {
            _settingsKey = ApplicationEnvironment.PreferencesSettingsRoot.GetSubSettings("WebProxy");
            if (ApplicationDiagnostics.ProxySettingsOverride != null)
            {
                Match m = Regex.Match(ApplicationDiagnostics.ProxySettingsOverride,
                                      @"^ ( (?<username>[^@:]+) : (?<password>[^@:]+) @)? (?<host>[^@:]+) (:(?<port>\d*))? $",
                                      RegexOptions.IgnorePatternWhitespace | RegexOptions.ExplicitCapture);
                if (m.Success)
                {
                    string username = m.Groups["username"].Value;
                    string password = m.Groups["password"].Value;
                    string host     = m.Groups["host"].Value;
                    string port     = m.Groups["port"].Value;

                    _readSettingsKey = new SettingsPersisterHelper(new MemorySettingsPersister());

                    _readSettingsKey.SetBoolean("Enabled", true);

                    if (!string.IsNullOrEmpty(username))
                    {
                        _readSettingsKey.SetString("Username", username);
                    }
                    if (!string.IsNullOrEmpty(password))
                    {
                        _readSettingsKey.SetEncryptedString("Password", password);
                    }

                    _readSettingsKey.SetString("Hostname", host);

                    if (!string.IsNullOrEmpty(port))
                    {
                        _readSettingsKey.SetInt32("Port", int.Parse(port, CultureInfo.InvariantCulture));
                    }
                }
            }

            if (_readSettingsKey == null)
            {
                _readSettingsKey = _settingsKey;
            }
        }
        /// <summary>
        /// Saves a destination profile into the registry.
        /// </summary>
        /// <param name="key"></param>
        /// <param name="profile"></param>
        public void saveProfile(String key, DestinationProfile profile)
        {
            SettingsPersisterHelper settings = getProfileSettings(key);

            profile.Id = key;
            settings.SetString(PROFILE_NAME_KEY, profile.Name);
            settings.SetString(PROFILE_WEBSITE_URL_KEY, profile.WebsiteURL);
            settings.SetString(PROFILE_FTP_SERVER_KEY, profile.FtpServer);
            settings.SetString(PROFILE_FTP_PUBLISH_DIR_KEY, profile.FtpPublishPath);
            settings.SetString(PROFILE_FTP_USER_KEY, profile.UserName);
            settings.SetString(PROFILE_PUBLISH_DIR_KEY, profile.LocalPublishPath);
            settings.SetInt32(PROFILE_DESTINATION_TYPE_KEY, (short)profile.Type);

            //save an encrypted password
            try
            {
                settings.SetEncryptedString(PROFILE_FTP_PASSWORD_KEY, profile.Password);
            }
            catch (Exception e)
            {
                //if an exception occurs, just leave the password empty
                Trace.Fail("Failed to encrypt password: " + e.Message, e.StackTrace);
            }
        }