/// <summary> /// Helper method to get a value from config /// </summary> /// <typeparam name="TReturnType"></typeparam> /// <param name="name"></param> /// <param name="required"></param> /// <param name="defaultValue"></param> /// <param name="lockObject"></param> /// <returns></returns> public static TReturnType LoadAppSetting <TReturnType>(string name, bool required, TReturnType defaultValue) { // Check for missing settings if (!ArrayExt.Contains <string>(ConfigurationManager.AppSettings.AllKeys, name)) { if (required) { throw new ConfigurationErrorsException(string.Format("Required setting missing: {0}", name)); } else { return(defaultValue); } } // Read the setting and return it AppSettingsReader reader = new AppSettingsReader(); return((TReturnType)reader.GetValue(name, typeof(TReturnType))); }