本文整理汇总了VB.NET中System.Web.Management.WebBaseEventCollection类的典型用法代码示例。如果您正苦于以下问题:VB.NET WebBaseEventCollection类的具体用法?VB.NET WebBaseEventCollection怎么用?VB.NET WebBaseEventCollection使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了WebBaseEventCollection类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的VB.NET代码示例。
示例1: SampleWebBaseEventCollection
' 导入命名空间
Imports System.Text
Imports System.Web
Imports System.Web.Management
Imports System.Collections
' Implements a custom WebBaseEvent class.
' Everytime this class is instantiated a WebBaseEvent is
' created. This event object is then added to the static
' simulatedEvents array list.
Public Class SampleWebBaseEventCollection
Inherits System.Web.Management.WebBaseEvent
Private customCreatedMsg As String
Private Shared simulatedEvents As New ArrayList()
Private Shared events _
As System.Web.Management.WebBaseEventCollection
' Create a new WebBaseEvent and add it to the
' static array list simulatedEvents.
Public Sub New(ByVal msg As String, ByVal eventSource As Object, _
ByVal eventCode As Integer)
MyBase.New(msg, eventSource, eventCode)
customCreatedMsg = String.Format("Event created at: {0}", _
DateTime.Now.TimeOfDay.ToString())
simulatedEvents.Add(Me)
End Sub
' Get the event with the specified index.
Public Shared Function GetItem(ByVal index _
As Integer) As WebBaseEvent
Return events(index)
End Function 'GetItem
' Get the index of the specified event.
Public Shared Function GetIndexOf(ByVal ev _
As WebBaseEvent) As Integer
Return events.IndexOf(ev)
End Function 'GetIndexOf
' Chek if the specified event is in the collection.
Public Shared Function ContainsEvent(ByVal ev _
As WebBaseEvent) As Boolean
Return events.Contains(ev)
End Function 'ContainsEvent
' Create an event collection.
' Add to it the created simulatedEvents.
Public Shared Sub AddEvents()
events = _
New System.Web.Management.WebBaseEventCollection(simulatedEvents)
End Sub
' Display the events contained in the collection.
Public Overrides Sub FormatCustomEventDetails(ByVal formatter _
As WebEventFormatter)
MyBase.FormatCustomEventDetails(formatter)
' Add custom data.
formatter.AppendLine("")
formatter.IndentationLevel += 1
formatter.AppendLine("**SampleWebBaseEventCollection Data Start **")
Dim ev As WebBaseEvent
For Each ev In events
formatter.AppendLine(String.Format("Message: {0}", _
ev.Message))
formatter.AppendLine(String.Format("Source: {0}", _
ev.EventSource.ToString()))
formatter.AppendLine(String.Format("Code: {0}", _
ev.EventCode.ToString()))
Next ev
formatter.AppendLine("**SampleWebBaseEventCollection Data End **")
formatter.IndentationLevel -= 1
End Sub
End Class