WebBaseEventCollection Clase

Definición

Contiene una colección de objetos WebBaseEvent. Esta clase no puede heredarse.

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
Herencia
WebBaseEventCollection

Ejemplos

En el ejemplo de código siguiente se muestra cómo se utiliza la clase 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

Comentarios

ASP.NET supervisión de estado permite al personal de producción y de operaciones administrar las aplicaciones web implementadas. El System.Web.Management espacio de nombres contiene los tipos de eventos de mantenimiento responsables de empaquetar los datos de estado de mantenimiento de la aplicación y los tipos de proveedor responsables de procesar estos datos. También contiene tipos auxiliares que ayudan durante la administración de eventos de mantenimiento.

La WebBaseEventCollection clase se usa para entregar una colección de eventos de supervisión de estado a proveedores como SqlWebEventProvider.

Constructores

WebBaseEventCollection(ICollection)

Inicializa una nueva instancia de la clase WebBaseEventCollection.

Propiedades

Count

Obtiene el número de elementos contenidos en la instancia de ReadOnlyCollectionBase.

(Heredado de ReadOnlyCollectionBase)
InnerList

Obtiene la lista de elementos incluidos en la instancia de ReadOnlyCollectionBase.

(Heredado de ReadOnlyCollectionBase)
Item[Int32]

Obtiene el objeto WebBaseEvent en el índice especificado.

Métodos

Contains(WebBaseEvent)

Indica si la colección contiene el objeto WebBaseEvent especificado.

Equals(Object)

Determina si el objeto especificado es igual que el objeto actual.

(Heredado de Object)
GetEnumerator()

Devuelve un enumerador que recorre en iteración la instancia de ReadOnlyCollectionBase.

(Heredado de ReadOnlyCollectionBase)
GetHashCode()

Sirve como la función hash predeterminada.

(Heredado de Object)
GetType()

Obtiene el Type de la instancia actual.

(Heredado de Object)
IndexOf(WebBaseEvent)

Obtiene el índice del objeto WebBaseEvent especificado.

MemberwiseClone()

Crea una copia superficial del Object actual.

(Heredado de Object)
ToString()

Devuelve una cadena que representa el objeto actual.

(Heredado de Object)

Implementaciones de interfaz explícitas

ICollection.CopyTo(Array, Int32)

Copia la totalidad de ReadOnlyCollectionBase en una matriz Array unidimensional compatible, comenzando en el índice especificado de la matriz de destino.

(Heredado de ReadOnlyCollectionBase)
ICollection.IsSynchronized

Obtiene un valor que indica si el acceso a un objeto ReadOnlyCollectionBase está sincronizado (es seguro para subprocesos).

(Heredado de ReadOnlyCollectionBase)
ICollection.SyncRoot

Obtiene un objeto que se puede utilizar para sincronizar el acceso a un objeto ReadOnlyCollectionBase.

(Heredado de ReadOnlyCollectionBase)

Métodos de extensión

Cast<TResult>(IEnumerable)

Convierte los elementos de IEnumerable en el tipo especificado.

OfType<TResult>(IEnumerable)

Filtra los elementos de IEnumerable en función de un tipo especificado.

AsParallel(IEnumerable)

Habilita la paralelización de una consulta.

AsQueryable(IEnumerable)

Convierte una interfaz IEnumerable en IQueryable.

Se aplica a

Consulte también