RuleSettingsCollection.Add(RuleSettings) Método

Definição

Adiciona um RuleSettings objeto à coleção.

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)

Parâmetros

ruleSettings
RuleSettings

Um RuleSettings objeto para adicionar à coleção.

Exceções

O RuleSettings objeto a adicionar já existe na coleção ou a coleção é apenas de leitura.

Exemplos

O exemplo de código a seguir mostra como usar o Add método. Este exemplo de código faz parte de um exemplo maior fornecido para a 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)

Observações

A coleção não deve já conter um RuleSettings objeto com o mesmo nome.

Aplica-se a

Ver também