/// <summary> /// Gets the configuration section using the specified element name. /// </summary> /// <exception cref="ConfigurationException"></exception> /// <remarks> /// If an HttpContext exists, uses the WebConfigurationManager /// to get the configuration section from web.config. /// </remarks> public static CompressionConfiguration GetSection(string definedName) { if (_section == null) { string cfgFileName = ".config"; if (HttpContext.Current == null) { _section = ConfigurationManager.GetSection(definedName) as CompressionConfiguration; } else { _section = WebConfigurationManager.GetSection(definedName) as CompressionConfiguration; cfgFileName = "web.config"; } if (_section == null) { throw new ConfigurationErrorsException("The <" + definedName + "> section is not defined in your " + cfgFileName + " file!"); } } return(_section); }
/// <summary> /// Gets the configuration section using the specified element name. /// </summary> /// <exception cref="ConfigurationException"></exception> /// <remarks> /// If an HttpContext exists, uses the WebConfigurationManager /// to get the configuration section from web.config. /// </remarks> public static CompressionConfiguration GetSection(string definedName) { if (_section == null) { string cfgFileName = ".config"; if (HttpContext.Current == null) { _section = ConfigurationManager.GetSection(definedName) as CompressionConfiguration; } else { _section = WebConfigurationManager.GetSection(definedName) as CompressionConfiguration; cfgFileName = "web.config"; } if (_section == null) { throw new ConfigurationErrorsException("The <" + definedName + "> section is not defined in your " + cfgFileName + " file!"); } } return _section; }