private static ProjectDirectorConfig getPDConfig() { ProjectDirectorConfig config = new ProjectDirectorConfig(); string url = ConfigurationManager.AppSettings[CONFIG_URL]; if (String.IsNullOrEmpty(url)) { throw new Exception("Configuration option '" + CONFIG_URL + "' is not set"); } else { config.url = url; } string username = ConfigurationManager.AppSettings[CONFIG_USERNAME]; if (String.IsNullOrEmpty(username)) { throw new Exception("Configuration option '" + CONFIG_USERNAME + "' is not set"); } else { config.username = username; } string password = ConfigurationManager.AppSettings[CONFIG_PASSWORD]; if (String.IsNullOrEmpty(password)) { throw new Exception("Configuration option '" + CONFIG_PASSWORD + "' is not set"); } else { config.password = password; } string userAgent = ConfigurationManager.AppSettings[CONFIG_USERAGENT]; if (String.IsNullOrEmpty(userAgent)) { System.Console.WriteLine(CONFIG_USERAGENT + " is not set. Using default '" + DEFAULT_USER_AGENT + "'."); userAgent = DEFAULT_USER_AGENT; } config.userAgent = userAgent; return(config); }
private ProjectDirectorConfig GetProjectDirectorConfig(NameValueCollection sitefinityConfig) { ProjectDirectorConfig projectDirectorConfig = new ProjectDirectorConfig(); string url = sitefinityConfig[ConfigKeyConstants.UrlKey]; if (string.IsNullOrEmpty(url)) { this.ThrowConfigurationMissingError(ConfigKeyConstants.UrlKey); } else { projectDirectorConfig.url = url; } string username = sitefinityConfig[ConfigKeyConstants.UsernameKey]; if (string.IsNullOrEmpty(username)) { this.ThrowConfigurationMissingError(ConfigKeyConstants.UsernameKey); } else { projectDirectorConfig.username = username; } string password = sitefinityConfig[ConfigKeyConstants.PasswordKey]; if (string.IsNullOrEmpty(password)) { this.ThrowConfigurationMissingError(ConfigKeyConstants.PasswordKey); } else { projectDirectorConfig.password = password; } string userAgent = sitefinityConfig[ConfigKeyConstants.UseragentKey]; if (string.IsNullOrEmpty(userAgent)) { userAgent = "Sitefinity"; } projectDirectorConfig.userAgent = userAgent; return(projectDirectorConfig); }