Partager via


RuleSettingsCollection.Add(RuleSettings) Méthode

Définition

Ajoute un objet RuleSettings à la collection.

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)

Paramètres

ruleSettings
RuleSettings

Objet RuleSettings à ajouter à la collection.

Exceptions

L'objet RuleSettings à ajouter existe déjà dans la collection ou la collection est en lecture seule.

Exemples

L'exemple de code suivant montre comment utiliser la méthode Add. Cet exemple de code fait partie d’un exemple plus grand fourni pour la HealthMonitoringSection classe.

// 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)

Remarques

La collection ne doit pas déjà contenir d’objet RuleSettings portant le même nom.

S’applique à

Voir aussi