/// <summary> /// Returns the default Account Name /// </summary> /// <returns></returns> private Account GetAccount(Dictionary<string, string> config, string apiUserName) { foreach (KeyValuePair<string, string> kvPair in config) { if(kvPair.Key.EndsWith(".apiUsername")) { if (apiUserName == null || apiUserName.Equals(kvPair.Value)) { int index = Convert.ToInt32(kvPair.Key.Substring(accountPrefix.Length, kvPair.Key.IndexOf('.') - accountPrefix.Length )); Account accnt = new Account(); if (config.ContainsKey(accountPrefix + index + ".apiUsername")) { accnt.APIUserName = config[accountPrefix + index + ".apiUsername"]; } if(config.ContainsKey(accountPrefix + index + ".apiPassword")) { accnt.APIPassword = config[accountPrefix + index + ".apiPassword"]; } if(config.ContainsKey(accountPrefix + index + ".apiSignature")) { accnt.APISignature = config[accountPrefix + index + ".apiSignature"]; } if(config.ContainsKey(accountPrefix + index + ".apiCertificate")) { accnt.APICertificate = config[accountPrefix + index + ".apiCertificate"]; } if (config.ContainsKey(accountPrefix + index + ".privateKeyPassword")) { accnt.PrivateKeyPassword = config[accountPrefix + index + ".privateKeyPassword"]; } if(config.ContainsKey(accountPrefix + index + ".subject")) { accnt.CertificateSubject = config[accountPrefix + index + ".subject"]; } if(config.ContainsKey(accountPrefix + index + ".applicationId")) { accnt.ApplicationId = config[accountPrefix + index + ".applicationId"]; } return accnt; } } } return null; }
/// <summary> /// Returns the default Account Name /// </summary> /// <returns></returns> private Account GetAccount(Dictionary<string, string> config, string apiUsername) { foreach (KeyValuePair<string, string> kvPair in config) { if(kvPair.Key.EndsWith(".apiUsername")) { if (apiUsername == null || apiUsername.Equals(kvPair.Value)) { string s = kvPair.Key.Substring(ACCOUNT_PREFIX.Length, kvPair.Key.IndexOf('.') - ACCOUNT_PREFIX.Length ); int i = Int32.Parse(kvPair.Key.Substring(ACCOUNT_PREFIX.Length, kvPair.Key.IndexOf('.') - ACCOUNT_PREFIX.Length )); Account acct = new Account(); if (config.ContainsKey(ACCOUNT_PREFIX + i + ".apiUsername")) { acct.APIUsername = config[ACCOUNT_PREFIX + i + ".apiUsername"]; } if(config.ContainsKey(ACCOUNT_PREFIX + i + ".apiPassword")) { acct.APIPassword = config[ACCOUNT_PREFIX + i + ".apiPassword"]; } if(config.ContainsKey(ACCOUNT_PREFIX + i + ".apiSignature")) { acct.APISignature = config[ACCOUNT_PREFIX + i + ".apiSignature"]; } if(config.ContainsKey(ACCOUNT_PREFIX + i + ".apiCertificate")) { acct.APICertificate = config[ACCOUNT_PREFIX + i + ".apiCertificate"]; } if (config.ContainsKey(ACCOUNT_PREFIX + i + ".privateKeyPassword")) { acct.PrivateKeyPassword = config[ACCOUNT_PREFIX + i + ".privateKeyPassword"]; } if(config.ContainsKey(ACCOUNT_PREFIX + i + ".subject")) { acct.CertificateSubject = config[ACCOUNT_PREFIX + i + ".subject"]; } if(config.ContainsKey(ACCOUNT_PREFIX + i + ".applicationId")) { acct.ApplicationId = config[ACCOUNT_PREFIX + i + ".applicationId"]; } return acct; } } } return null; }