//----------------------------------------------------------------------- // // Copyright (c) Outercurve Foundation. All rights reserved. // //----------------------------------------------------------------------- namespace DotNetOpenAuth.Configuration { using System; using System.Configuration; using System.Web; using System.Web.Configuration; /// /// Represents the section in the host's .config file that configures /// this library's settings. /// public class DotNetOpenAuthSection : ConfigurationSectionGroup { /// /// The name of the section under which this library's settings must be found. /// internal const string SectionName = "dotNetOpenAuth"; /// /// The name of the <openid> sub-element. /// private const string OpenIdElementName = "openid"; /// /// The name of the <oauth> sub-element. /// private const string OAuthElementName = "oauth"; /// /// Initializes a new instance of the class. /// internal DotNetOpenAuthSection() { } /// /// Gets the messaging configuration element. /// public static MessagingElement Messaging { get { return MessagingElement.Configuration; } } /// /// Gets the reporting configuration element. /// internal static ReportingElement Reporting { get { return ReportingElement.Configuration; } } /// /// Gets a named section in this section group, or null if no such section is defined. /// /// The name of the section to obtain. /// The desired section, or null if it could not be obtained. internal static ConfigurationSection GetNamedSection(string name) { string fullyQualifiedSectionName = SectionName + "/" + name; if (HttpContext.Current != null) { return (ConfigurationSection)WebConfigurationManager.GetSection(fullyQualifiedSectionName); } else { var configuration = ConfigurationManager.OpenExeConfiguration(null); return configuration != null ? configuration.GetSection(fullyQualifiedSectionName) : null; } } } }