//----------------------------------------------------------------------- // // Copyright (c) Outercurve Foundation. All rights reserved. // //----------------------------------------------------------------------- namespace DotNetOpenAuth.Configuration { using System; using System.Collections.Generic; using System.Configuration; using System.Linq; using System.Text; /// /// Represents the <reporting> element in the host's .config file. /// internal class ReportingElement : ConfigurationSection { /// /// The name of the @enabled attribute. /// private const string EnabledAttributeName = "enabled"; /// /// The name of the @minimumReportingInterval attribute. /// private const string MinimumReportingIntervalAttributeName = "minimumReportingInterval"; /// /// The name of the @minimumFlushInterval attribute. /// private const string MinimumFlushIntervalAttributeName = "minimumFlushInterval"; /// /// The name of the @includeFeatureUsage attribute. /// private const string IncludeFeatureUsageAttributeName = "includeFeatureUsage"; /// /// The name of the @includeEventStatistics attribute. /// private const string IncludeEventStatisticsAttributeName = "includeEventStatistics"; /// /// The name of the @includeLocalRequestUris attribute. /// private const string IncludeLocalRequestUrisAttributeName = "includeLocalRequestUris"; /// /// The name of the @includeCultures attribute. /// private const string IncludeCulturesAttributeName = "includeCultures"; /// /// The name of the <reporting> sub-element. /// private const string ReportingElementName = DotNetOpenAuthSection.SectionName + "/reporting"; /// /// The default value for the @minimumFlushInterval attribute. /// #if DEBUG private const string MinimumFlushIntervalDefault = "0"; #else private const string MinimumFlushIntervalDefault = "0:15"; #endif /// /// Initializes a new instance of the class. /// internal ReportingElement() { } /// /// Gets the configuration section from the .config file. /// public static ReportingElement Configuration { get { return (ReportingElement)ConfigurationManager.GetSection(ReportingElementName) ?? new ReportingElement(); } } /// /// Gets or sets a value indicating whether this reporting is enabled. /// /// true if enabled; otherwise, false. [ConfigurationProperty(EnabledAttributeName, DefaultValue = true)] internal bool Enabled { get { return (bool)this[EnabledAttributeName]; } set { this[EnabledAttributeName] = value; } } /// /// Gets or sets the maximum frequency that reports will be published. /// [ConfigurationProperty(MinimumReportingIntervalAttributeName, DefaultValue = "1")] // 1 day default internal TimeSpan MinimumReportingInterval { get { return (TimeSpan)this[MinimumReportingIntervalAttributeName]; } set { this[MinimumReportingIntervalAttributeName] = value; } } /// /// Gets or sets the maximum frequency the set can be flushed to disk. /// [ConfigurationProperty(MinimumFlushIntervalAttributeName, DefaultValue = MinimumFlushIntervalDefault)] internal TimeSpan MinimumFlushInterval { get { return (TimeSpan)this[MinimumFlushIntervalAttributeName]; } set { this[MinimumFlushIntervalAttributeName] = value; } } /// /// Gets or sets a value indicating whether to include a list of library features used in the report. /// /// true to include a report of features used; otherwise, false. [ConfigurationProperty(IncludeFeatureUsageAttributeName, DefaultValue = true)] internal bool IncludeFeatureUsage { get { return (bool)this[IncludeFeatureUsageAttributeName]; } set { this[IncludeFeatureUsageAttributeName] = value; } } /// /// Gets or sets a value indicating whether to include statistics of certain events such as /// authentication success and failure counting, and can include remote endpoint URIs. /// /// /// true to include event counters in the report; otherwise, false. /// [ConfigurationProperty(IncludeEventStatisticsAttributeName, DefaultValue = true)] internal bool IncludeEventStatistics { get { return (bool)this[IncludeEventStatisticsAttributeName]; } set { this[IncludeEventStatisticsAttributeName] = value; } } /// /// Gets or sets a value indicating whether to include a few URLs to pages on the hosting /// web site that host DotNetOpenAuth components. /// [ConfigurationProperty(IncludeLocalRequestUrisAttributeName, DefaultValue = true)] internal bool IncludeLocalRequestUris { get { return (bool)this[IncludeLocalRequestUrisAttributeName]; } set { this[IncludeLocalRequestUrisAttributeName] = value; } } /// /// Gets or sets a value indicating whether to include the cultures requested by the user agent /// on pages that host DotNetOpenAuth components. /// [ConfigurationProperty(IncludeCulturesAttributeName, DefaultValue = true)] internal bool IncludeCultures { get { return (bool)this[IncludeCulturesAttributeName]; } set { this[IncludeCulturesAttributeName] = value; } } } }