RuleSettingsCollection.Add(RuleSettings) 方法
定义
将 RuleSettings 对象添加到集合中。Adds a RuleSettings object to the 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)
参数
- ruleSettings
- RuleSettings
要添加到集合的 RuleSettings 对象。A RuleSettings object to add to the collection.
例外
集合中已经存在要添加的 RuleSettings 对象或此集合为只读。The RuleSettings object to add already exists in the collection or the collection is read-only.
示例
下面的代码示例说明如何使用 Add 方法。The following code example shows how to use the Add method. 此代码示例是为类提供的更大示例的一部分 HealthMonitoringSection 。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);
' 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 具有相同名称的对象。The collection must not already contain a RuleSettings object with the same name.