private ConfigManager() { config = (SDKConfigHandler) ConfigurationManager.GetSection("paypal"); if (config == null) { throw new ConfigException("Cannot read config file"); } }
private ConfigManager() { config = (SDKConfigHandler)ConfigurationManager.GetSection("paypal"); if (config == null) { throw new ConfigException("Cannot read config file"); } }
/// <summary> /// Private constructor /// </summary> private ConfigManager() { SDKConfigHandler configHandler = (SDKConfigHandler)ConfigurationManager.GetSection("paypal"); if (configHandler == null) { throw new ConfigException("Cannot parse *.Config file. Ensure you have configured the 'paypal' section correctly."); } this.configValues = new Dictionary <string, string>(); NameValueConfigurationCollection settings = configHandler.Settings; foreach (string key in settings.AllKeys) { this.configValues.Add(settings[key].Name, settings[key].Value); } int index = 0; foreach (ConfigurationElement element in configHandler.Accounts) { Account account = (Account)element; if (!string.IsNullOrEmpty(account.APIUserName)) { this.configValues.Add("account" + index + ".apiUsername", account.APIUserName); } if (!string.IsNullOrEmpty(account.APIPassword)) { this.configValues.Add("account" + index + ".apiPassword", account.APIPassword); } if (!string.IsNullOrEmpty(account.APISignature)) { this.configValues.Add("account" + index + ".apiSignature", account.APISignature); } if (!string.IsNullOrEmpty(account.APICertificate)) { this.configValues.Add("account" + index + ".apiCertificate", account.APICertificate); } if (!string.IsNullOrEmpty(account.PrivateKeyPassword)) { this.configValues.Add("account" + index + ".privateKeyPassword", account.PrivateKeyPassword); } if (!string.IsNullOrEmpty(account.CertificateSubject)) { this.configValues.Add("account" + index + ".subject", account.CertificateSubject); } if (!string.IsNullOrEmpty(account.ApplicationId)) { this.configValues.Add("account" + index + ".applicationId", account.ApplicationId); } index++; } }
/// <summary> /// Private constructor /// </summary> private ConfigManager() { configHandler = (SDKConfigHandler)ConfigurationManager.GetSection("paypal"); if (configHandler == null) { throw new ConfigException("Cannot parse *.Config file. Ensure you have configured the 'paypal' section correctly."); } this.configValues = new Dictionary<string, string>(); NameValueConfigurationCollection settings = this.configHandler.Settings; foreach (string key in settings.AllKeys) { this.configValues.Add(settings[key].Name, settings[key].Value); } int i = 0; foreach (ConfigurationElement elem in this.configHandler.Accounts) { Account account = (Account)elem; if (account.APIUsername != null && account.APIUsername != "") { this.configValues.Add("account" + i + ".apiUsername", account.APIUsername); } if (account.APIPassword != null && account.APIPassword != "") { this.configValues.Add("account" + i + ".apiPassword", account.APIPassword); } if (account.APISignature != null && account.APISignature != "") { this.configValues.Add("account" + i + ".apiSignature", account.APISignature); } if (account.APICertificate != null && account.APICertificate != "") { this.configValues.Add("account" + i + ".apiCertificate", account.APICertificate); } if (account.PrivateKeyPassword != null && account.PrivateKeyPassword != "") { this.configValues.Add("account" + i + ".privateKeyPassword", account.PrivateKeyPassword); } if (account.CertificateSubject != null && account.CertificateSubject != "") { this.configValues.Add("account" + i + ".subject", account.CertificateSubject); } if (account.ApplicationId != null && account.ApplicationId != "") { this.configValues.Add("account" + i + ".applicationId", account.ApplicationId); } i++; } }