HealthMonitoringSection.EventMappings 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
public:
property System::Web::Configuration::EventMappingSettingsCollection ^ EventMappings { System::Web::Configuration::EventMappingSettingsCollection ^ get(); };
[System.Configuration.ConfigurationProperty("eventMappings")]
public System.Web.Configuration.EventMappingSettingsCollection EventMappings { get; }
[<System.Configuration.ConfigurationProperty("eventMappings")>]
member this.EventMappings : System.Web.Configuration.EventMappingSettingsCollection
Public ReadOnly Property EventMappings As EventMappingSettingsCollection
属性值
EventMappingSettingsCollection 对象的 EventMappingSettings 集合。 默认为空 EventMappingSettingsCollection 集合。
- 属性
示例
下面的代码示例说明如何使用 EventMappings 属性。 此代码示例是为类提供的大型示例的 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()