RuleSettingsCollection.Add(RuleSettings) Metod

Definition

Lägger till ett RuleSettings objekt i samlingen.

public:
 void Add(System::Web::Configuration::RuleSettings ^ ruleSettings);
public void Add(System.Web.Configuration.RuleSettings ruleSettings);
member this.Add : System.Web.Configuration.RuleSettings -> unit
Public Sub Add (ruleSettings As RuleSettings)

Parametrar

ruleSettings
RuleSettings

Ett RuleSettings objekt som ska läggas till i samlingen.

Undantag

Objektet RuleSettings som ska läggas till finns redan i samlingen eller så är samlingen skrivskyddad.

Exempel

I följande kodexempel visas hur metoden Add används. Det här kodexemplet är en del av ett större exempel för HealthMonitoringSection klassen.

// 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);
' Add a RuleSettings object to the Rules collection property.
Dim ruleSetting As RuleSettings = 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)

Kommentarer

Samlingen får inte redan innehålla ett RuleSettings objekt med samma namn.

Gäller för

Se även