/// <summary> /// This method reads and decrypts the values /// in the app.config appSettings section. /// </summary> /// <param name="settingName"></param> /// <returns></returns> private string ReadAppSetting(string settingName) { // initial value string settingValue = null; try { // if UseEncryption is true and the EncryptionKey exists if ((UseEncryption) && (HasEncryptionKey)) { // encrypted value string encryptedValue = ConfigurationManager.AppSettings[settingName].ToString(); // now decrypt value with EncryptionKey settingValue = CryptographyManager.DecryptString(encryptedValue, this.EncryptionKey); } else { // read the setting value as is settingName = ConfigurationManager.AppSettings[settingName].ToString(); } } catch (Exception error) { // set the last error this.LastError = error; } // return value return(settingValue); }
/// <summary> /// This method reads and decrypts the values /// in the app.config appSettings section. /// </summary> /// <param name="settingName"></param> /// <returns></returns> private bool ReadBooleanAppSetting(string settingName, bool defaultValue) { // initial value bool settingValue = defaultValue; try { // encrypted value string encryptedValue = ConfigurationManager.AppSettings[settingName].ToString(); // now decrypt value settingValue = Convert.ToBoolean(CryptographyManager.DecryptString(encryptedValue)); } catch (Exception error) { // If ErrorProcessor exists if (this.ErrorProcessor != null) { // locals string methodName = "ReadAppSetting"; string objectName = "ApplicationLogicComponent.StartUp.RADApplicationConfiguration"; // Log the current error this.ErrorProcessor.LogError(methodName, objectName, error); } } // return value return(settingValue); }