EventMappingSettingsCollection 类
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
提供 EventMappingSettings 对象的集合。 此类不能被继承。
public ref class EventMappingSettingsCollection sealed : System::Configuration::ConfigurationElementCollection
[System.Configuration.ConfigurationCollection(typeof(System.Web.Configuration.EventMappingSettings))]
public sealed class EventMappingSettingsCollection : System.Configuration.ConfigurationElementCollection
[<System.Configuration.ConfigurationCollection(typeof(System.Web.Configuration.EventMappingSettings))>]
type EventMappingSettingsCollection = class
inherit ConfigurationElementCollection
Public NotInheritable Class EventMappingSettingsCollection
Inherits ConfigurationElementCollection
- 继承
- 属性
示例
下面的代码示例演示如何使用 EventMappingSettingsCollection 类型。 此代码示例是为 HealthMonitoringSection 类提供的一个更大示例的一部分。
// Add a EventMappingsSettings object to the EventMappings collection property.
EventMappingSettings eventMappingSetting = new EventMappingSettings(
"Failure Audits", "System.Web.Management.WebAuditEvent, System.Web");
eventMappingSetting.Name = "All Errors";
eventMappingSetting.Type =
"System.Web.Management.WebErrorEvent, System.Web";
eventMappingSetting.StartEventCode = 0;
eventMappingSetting.EndEventCode = 4096;
healthMonitoringSection.EventMappings.Add(eventMappingSetting);
// Add an EventMappingsSettings object to the EventMappings collection property.
healthMonitoringSection.EventMappings.Add(new EventMappingSettings(
"Failure Audits", "System.Web.Management.WebAuditEvent, System.Web"));
// Add an EventMappingsSettings object to the EventMappings collection property.
healthMonitoringSection.EventMappings.Add(new EventMappingSettings(
"Success Audits", "System.Web.Management.WebAuditEvent, System.Web",
512, Int32.MaxValue));
// Insert an EventMappingsSettings object into the EventMappings collection property.
healthMonitoringSection.EventMappings.Insert(1,
new EventMappingSettings("HeartBeats", "", 1, 2));
// Display contents of the EventMappings collection property
Console.WriteLine(
"EventMappings Collection contains {0} values:", healthMonitoringSection.EventMappings.Count);
// Display all elements.
for (System.Int32 i = 0; i < healthMonitoringSection.EventMappings.Count; i++)
{
eventMappingSetting = healthMonitoringSection.EventMappings[i];
string name = eventMappingSetting.Name;
string type = eventMappingSetting.Type;
int startCd = eventMappingSetting.StartEventCode;
int endCd = eventMappingSetting.EndEventCode;
string item = "Name='" + name + "', Type='" + type +
"', StartEventCode = '" + startCd.ToString() +
"', EndEventCode = '" + endCd.ToString() + "'";
Console.WriteLine(" Item {0}: {1}", i, item);
}
// See if the EventMappings collection property contains the event 'HeartBeats'.
Console.WriteLine("EventMappings contains 'HeartBeats': {0}.",
healthMonitoringSection.EventMappings.Contains("HeartBeats"));
// Get the index of the 'HeartBeats' event in the EventMappings collection property.
Console.WriteLine("EventMappings index for 'HeartBeats': {0}.",
healthMonitoringSection.EventMappings.IndexOf("HeartBeats"));
// Get a named EventMappings
eventMappingSetting = healthMonitoringSection.EventMappings["HeartBeats"];
// Remove an EventMappingsSettings object from the EventMappings collection property.
healthMonitoringSection.EventMappings.Remove("HeartBeats");
// Remove an EventMappingsSettings object from the EventMappings collection property.
healthMonitoringSection.EventMappings.RemoveAt(0);
// Clear all EventMappingsSettings object from the EventMappings collection property.
healthMonitoringSection.EventMappings.Clear();
' Add a EventMappingsSettings object to the EventMappings collection property.
Dim eventMappingSetting As EventMappingSettings = New EventMappingSettings( _
"Failure Audits", "System.Web.Management.WebAuditEvent, System.Web")
eventMappingSetting.Name = "All Errors"
eventMappingSetting.Type = _
"System.Web.Management.WebErrorEvent, System.Web"
eventMappingSetting.StartEventCode = 0
eventMappingSetting.EndEventCode = 4096
healthMonitoringSection.EventMappings.Add(eventMappingSetting)
' Add an EventMappingsSettings object to the EventMappings collection property.
healthMonitoringSection.EventMappings.Add(new EventMappingSettings( _
"Failure Audits", "System.Web.Management.WebAuditEvent, System.Web"))
' Add an EventMappingsSettings object to the EventMappings collection property.
healthMonitoringSection.EventMappings.Add(new EventMappingSettings( _
"Success Audits", "System.Web.Management.WebAuditEvent, System.Web", _
512, Int32.MaxValue))
' Insert an EventMappingsSettings object into the EventMappings collection property.
healthMonitoringSection.EventMappings.Insert(1, _
new EventMappingSettings("HeartBeats", "", 1, 2))
' Display contents of the EventMappings collection property
Console.WriteLine( _
"EventMappings Collection contains {0} values:", healthMonitoringSection.EventMappings.Count)
' Display all elements.
For i As System.Int32 = 0 To healthMonitoringSection.EventMappings.Count - 1
eventMappingSetting = healthMonitoringSection.EventMappings(i)
Dim name As String = eventMappingSetting.Name
Dim type As String = eventMappingSetting.Type
Dim startCd As Integer = eventMappingSetting.StartEventCode
Dim endCd As Integer = eventMappingSetting.EndEventCode
Dim item As String = "Name='" & name & "', Type='" & type & _
"', StartEventCode = '" & startCd.ToString() & _
"', EndEventCode = '" & endCd.ToString() & "'"
Console.WriteLine(" Item {0}: {1}", i, item)
Next
' See if the EventMappings collection property contains the event 'HeartBeats'.
Console.WriteLine("EventMappings contains 'HeartBeats': {0}.", _
healthMonitoringSection.EventMappings.Contains("HeartBeats"))
' Get the index of the 'HeartBeats' event in the EventMappings collection property.
Console.WriteLine("EventMappings index for 'HeartBeats': {0}.", _
healthMonitoringSection.EventMappings.IndexOf("HeartBeats"))
' Get a named EventMappings
eventMappingSetting = healthMonitoringSection.EventMappings("HeartBeats")
' Remove an EventMappingsSettings object from the EventMappings collection property.
healthMonitoringSection.EventMappings.Remove("HeartBeats")
' Remove an EventMappingsSettings object from the EventMappings collection property.
healthMonitoringSection.EventMappings.RemoveAt(0)
' Clear all EventMappingsSettings object from the EventMappings collection property.
healthMonitoringSection.EventMappings.Clear()
注解
类 EventMappingSettings 对应于 eventMappings
配置文件元素。 元素 eventMappings
允许向事件源分配友好名称。 然后,这些名称用于将事件源与配置文件 的 节的 rules
子部分中 healthMonitoring
的相关事件使用者(称为提供程序)相关联。
构造函数
EventMappingSettingsCollection() |
初始化 EventMappingSettingsCollection 类的新实例。 |
属性
方法
显式接口实现
ICollection.CopyTo(Array, Int32) |
将 ConfigurationElementCollection 复制到数组。 (继承自 ConfigurationElementCollection) |
扩展方法
Cast<TResult>(IEnumerable) |
将 IEnumerable 的元素强制转换为指定的类型。 |
OfType<TResult>(IEnumerable) |
根据指定类型筛选 IEnumerable 的元素。 |
AsParallel(IEnumerable) |
启用查询的并行化。 |
AsQueryable(IEnumerable) |
将 IEnumerable 转换为 IQueryable。 |