Export (0) Print
Expand All

RuleSettings Class

Configures the ASP.NET event rules. This class cannot be inherited.

Namespace: System.Web.Configuration
Assembly: System.Web (in system.web.dll)

public sealed class RuleSettings : ConfigurationElement
public final class RuleSettings extends ConfigurationElement
public final class RuleSettings extends ConfigurationElement
Not applicable.

Event rules determine which event, using which profile, is fired to which provider.

The following configuration file excerpt shows how to declaratively specify the properties of the RuleSettings class.

<healthMonitoring>
    <rules>
        <add name="All Errors Default"
            eventName="All Errors"
            provider="EventLogProvider"
            profile="Default"
            minInterval="00:01:00" 
        />
        <add name="All Audits Default"
            eventName="All Audits"
            provider="SqlWebEventProvider"
            profile="Default"
            minInterval="00:00:30" 
        />
        <add name="Failure Audits Default"
            eventName="Failure Audits"
            provider="WmiWebEventProvider"
            profile="Critical"
            minInterval="00:00:30" 
        />
        <add name="Request Processing Errors"
            eventName="Request Processing Errors"
            provider="CriticalMailEventProvider"
            profile="Default"
        />
        <add name="Infrastructure Notifications"
            eventName="Infrastructure Errors"
            provider="CriticalMailEventProvider"
            profile="Critical"
        />
   </rules>
</healthMonitoring>

The following code example shows how to create and set the values of the RuleSettings type. This code example is part of a larger example provided for the HealthMonitoringSection class.

// Add a RuleSettings object to the Rules collection property.
RuleSettings ruleSetting = new RuleSettings("All Errors Default",
    "All Errors", "EventLogProvider");
ruleSetting.Name = "All Errors Custom";
ruleSetting.EventName = "All Errors";
ruleSetting.Provider = "EventLogProvider";
ruleSetting.Profile = "Custom";
ruleSetting.MaxLimit = Int32.MaxValue;
ruleSetting.MinInstances = 1;
ruleSetting.MinInterval = TimeSpan.Parse("00:00:30");
ruleSetting.Custom = "MyEvaluators.MyCustomeEvaluator2, MyCustom.dll";
healthMonitoringSection.Rules.Add(ruleSetting);

The following code example shows how to get and display the values of the RuleSettings type. This code example is part of a larger example provided for the HealthMonitoringSection class.

// Display contents of the Rules collection property
Console.WriteLine(
    "Rules Collection contains {0} values:", healthMonitoringSection.Rules.Count);

// Display all elements.
for (System.Int32 i = 0; i < healthMonitoringSection.Rules.Count; i++)
{
ruleSetting = healthMonitoringSection.Rules[i];
string name = ruleSetting.Name;
string eventName = ruleSetting.EventName;
string provider = ruleSetting.Provider;
string profile = ruleSetting.Profile;
int minInstances = ruleSetting.MinInstances;
int maxLimit = ruleSetting.MaxLimit;
TimeSpan minInterval = ruleSetting.MinInterval;
string custom = ruleSetting.Custom;
    string item = "Name='" + name + "', EventName='" + eventName +
        "', Provider =  '" + provider + "', Profile =  '" + profile +
        "', MinInstances =  '" + minInstances + "', MaxLimit =  '" + maxLimit +
        "', MinInterval =  '" + minInterval + "', Custom =  '" + custom + "'";
    Console.WriteLine("  Item {0}: {1}", i, item);
}

System.Object
   System.Configuration.ConfigurationElement
    System.Web.Configuration.RuleSettings

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 98, Windows Server 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0

Community Additions

ADD
Show:
© 2014 Microsoft