RuleSettingsCollection.Add(RuleSettings) 方法

定义

RuleSettings 对象添加到集合中。

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)

参数

ruleSettings
RuleSettings

要添加到集合的 RuleSettings 对象。

例外

集合中已经存在要添加的 RuleSettings 对象或此集合为只读。

示例

下面的代码示例说明如何使用 Add 方法。 此代码示例是为类提供的大型示例的 HealthMonitoringSection 一部分。

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

注解

集合不能包含 RuleSettings 具有相同名称的对象。

适用于

另请参阅