/// <summary> /// Read all settings from App.config. /// </summary> /// <param name="settings">The parsed App.config settings.</param> protected override void ReadSettings(Hashtable settings) { base.ReadSettings(settings); try { authorizationMethod = (DfaAuthorizationMethod)Enum.Parse( typeof(DfaAuthorizationMethod), ReadSetting(settings, AUTHORIZATION_METHOD, authorizationMethod.ToString())); } catch { authorizationMethod = DEFAULT_AUTHORIZATION_METHOD; } dfaAuthToken = ReadSetting(settings, DFA_AUTHTOKEN, dfaAuthToken); dfaUserName = ReadSetting(settings, DFA_USERNAME, dfaUserName); dfaPassword = ReadSetting(settings, DFA_PASSWORD, dfaPassword); applicationName = ReadSetting(settings, APPLICATION_NAME, applicationName); dfaApiServer = ReadSetting(settings, DFAAPI_SERVER, dfaApiServer); // If there is an OAuth2 scope mentioned in App.config, this will be // loaded by the above call. If there isn't one, we will initialize it // with a library-specific default value. if (string.IsNullOrEmpty(this.OAuth2Scope)) { this.OAuth2Scope = GetDefaultOAuth2Scope(); } }
/// <summary> /// Public constructor. /// </summary> public DfaAppConfig() : base() { authorizationMethod = DEFAULT_AUTHORIZATION_METHOD; dfaAuthToken = ""; dfaUserName = null; dfaPassword = null; applicationName = ""; dfaApiServer = DEFAULT_DFAAPI_SERVER; ReadSettings((Hashtable)ConfigurationManager.GetSection("DfaApi")); }
/// <summary> /// Read all settings from App.config. /// </summary> /// <param name="settings">The parsed App.config settings.</param> protected override void ReadSettings(Hashtable settings) { base.ReadSettings(settings); try { authorizationMethod = (DfaAuthorizationMethod) Enum.Parse( typeof(DfaAuthorizationMethod), ReadSetting(settings, AUTHORIZATION_METHOD, authorizationMethod.ToString())); } catch { authorizationMethod = DEFAULT_AUTHORIZATION_METHOD; } dfaAuthToken = ReadSetting(settings, DFA_AUTHTOKEN, dfaAuthToken); dfaUserName = ReadSetting(settings, DFA_USERNAME, dfaUserName); dfaPassword = ReadSetting(settings, DFA_PASSWORD, dfaPassword); applicationName = ReadSetting(settings, APPLICATION_NAME, applicationName); dfaApiServer = ReadSetting(settings, DFAAPI_SERVER, dfaApiServer); // If there is an OAuth2 scope mentioned in App.config, this will be // loaded by the above call. If there isn't one, we will initialize it // with a library-specific default value. if (string.IsNullOrEmpty(this.OAuth2Scope)) { this.OAuth2Scope = GetDefaultOAuth2Scope(); } }
/// <summary> /// Public constructor. /// </summary> public DfaAppConfig() : base() { authorizationMethod = DEFAULT_AUTHORIZATION_METHOD; dfaAuthToken = ""; dfaUserName = null; dfaPassword = null; applicationName = ""; dfaApiServer = DEFAULT_DFAAPI_SERVER; ReadSettings((Hashtable) ConfigurationManager.GetSection("DfaApi")); }