WebBaseEventCollection Класс

Определение

Содержит коллекцию объектов WebBaseEvent. Этот класс не наследуется.

public ref class WebBaseEventCollection sealed : System::Collections::ReadOnlyCollectionBase
public sealed class WebBaseEventCollection : System.Collections.ReadOnlyCollectionBase
type WebBaseEventCollection = class
    inherit ReadOnlyCollectionBase
Public NotInheritable Class WebBaseEventCollection
Inherits ReadOnlyCollectionBase
Наследование
WebBaseEventCollection

Примеры

Приведенный ниже пример кода показывает, как использовать класс WebBaseEventCollection.


using System;
using System.Text;
using System.Web;
using System.Web.Management;
using System.Collections;

namespace SamplesAspNet
{
    // 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 : System.Web.Management.WebBaseEvent
    {
        private string customCreatedMsg;

        private static ArrayList simulatedEvents = new ArrayList();
        private static System.Web.Management.WebBaseEventCollection events;

        // Create a new WebBaseEvent and add it to the 
        // static array list simulatedEvents.
        public SampleWebBaseEventCollection(
        string msg, object eventSource, int eventCode):
        base(msg, eventSource, eventCode)
        {

            customCreatedMsg =
              string.Format("Event created at: {0}", 
              DateTime.Now.TimeOfDay.ToString());

            simulatedEvents.Add(this);
        }

        // Get the event with the specified index.
        public static WebBaseEvent GetItem(int index)
        {
            return events[index];
        }

        // Get the index of the specified event.
        public static int GetIndexOf(WebBaseEvent ev)
        {
            return events.IndexOf(ev);
        }

        // Check if the specified event is in the collection.
        public static bool ContainsEvent(WebBaseEvent ev)
        {
            return events.Contains(ev);
        }


        // Create an event collection.
        // Add to it the created simulatedEvents.
        public static void AddEvents()
        {
            events = 
            new System.Web.Management.WebBaseEventCollection(
            simulatedEvents);
        }


        // Display the events contained in the collection.
        public override void FormatCustomEventDetails(WebEventFormatter formatter)
        {
            base.FormatCustomEventDetails(formatter);
            // Add custom data.
            formatter.AppendLine("");

            formatter.IndentationLevel += 1;
            formatter.AppendLine(
                "**SampleWebBaseEventCollection Data Start **");
            foreach (WebBaseEvent 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()));
            }

            formatter.AppendLine(
                "**SampleWebBaseEventCollection Data End **");

            formatter.IndentationLevel -= 1;
        }
    }
}
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

Комментарии

ASP.NET мониторинг работоспособности позволяет рабочим и операционным сотрудникам управлять развернутыми веб-приложениями. Пространство System.Web.Management имен содержит типы событий работоспособности, ответственные за упаковку данных о состоянии работоспособности приложения, и типы поставщиков, ответственные за обработку этих данных. Он также содержит вспомогательные типы, которые помогают во время управления событиями работоспособности.

Класс WebBaseEventCollection используется для доставки коллекции событий мониторинга работоспособности поставщикам, таким как SqlWebEventProvider.

Конструкторы

WebBaseEventCollection(ICollection)

Инициализирует новый экземпляр класса WebBaseEventCollection.

Свойства

Count

Возвращает количество элементов, содержащихся в экземпляре ReadOnlyCollectionBase.

(Унаследовано от ReadOnlyCollectionBase)
InnerList

Получает список элементов, содержащихся в экземпляре ReadOnlyCollectionBase.

(Унаследовано от ReadOnlyCollectionBase)
Item[Int32]

Возвращает объект WebBaseEvent по указанному индексу.

Методы

Contains(WebBaseEvent)

Показывает, содержится ли в коллекции указанный объект WebBaseEvent.

Equals(Object)

Определяет, равен ли указанный объект текущему объекту.

(Унаследовано от Object)
GetEnumerator()

Возвращает перечислитель, перебирающий элементы экземпляра класса ReadOnlyCollectionBase.

(Унаследовано от ReadOnlyCollectionBase)
GetHashCode()

Служит хэш-функцией по умолчанию.

(Унаследовано от Object)
GetType()

Возвращает объект Type для текущего экземпляра.

(Унаследовано от Object)
IndexOf(WebBaseEvent)

Возвращает индекс указанного объекта WebBaseEvent.

MemberwiseClone()

Создает неполную копию текущего объекта Object.

(Унаследовано от Object)
ToString()

Возвращает строку, представляющую текущий объект.

(Унаследовано от Object)

Явные реализации интерфейса

ICollection.CopyTo(Array, Int32)

Копирует целый массив ReadOnlyCollectionBase в совместимый одномерный массив Array, начиная с заданного индекса целевого массива.

(Унаследовано от ReadOnlyCollectionBase)
ICollection.IsSynchronized

Возвращает значение, указывающее на то, является ли доступ к объекту ReadOnlyCollectionBase синхронизированным (потокобезопасным).

(Унаследовано от ReadOnlyCollectionBase)
ICollection.SyncRoot

Получает объект, который позволяет синхронизировать доступ к объекту ReadOnlyCollectionBase.

(Унаследовано от ReadOnlyCollectionBase)

Методы расширения

Cast<TResult>(IEnumerable)

Приводит элементы объекта IEnumerable к заданному типу.

OfType<TResult>(IEnumerable)

Выполняет фильтрацию элементов объекта IEnumerable по заданному типу.

AsParallel(IEnumerable)

Позволяет осуществлять параллельный запрос.

AsQueryable(IEnumerable)

Преобразовывает коллекцию IEnumerable в объект IQueryable.

Применяется к

См. также раздел