Export (0) Print
Expand All

WebBaseEventCollection Class

Contains a collection of WebBaseEvent objects. This class cannot be inherited.

System.Object
  System.Collections.ReadOnlyCollectionBase
    System.Web.Management.WebBaseEventCollection

Namespace:  System.Web.Management
Assembly:  System.Web (in System.Web.dll)

public sealed class WebBaseEventCollection : ReadOnlyCollectionBase

The WebBaseEventCollection type exposes the following members.

  NameDescription
Public methodWebBaseEventCollectionInitializes a new instance of the WebBaseEventCollection class.
Top

  NameDescription
Public propertyCountGets the number of elements contained in the ReadOnlyCollectionBase instance. (Inherited from ReadOnlyCollectionBase.)
Public propertyItemGets the WebBaseEvent object at the specified index.
Top

  NameDescription
Public methodContainsIndicates whether the collection contains the specified WebBaseEvent object.
Public methodEquals(Object)Determines whether the specified object is equal to the current object. (Inherited from Object.)
Public methodGetEnumeratorReturns an enumerator that iterates through the ReadOnlyCollectionBase instance. (Inherited from ReadOnlyCollectionBase.)
Public methodGetHashCodeServes as the default hash function. (Inherited from Object.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Public methodIndexOfGets the index of the specified WebBaseEvent object.
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)
Top

  NameDescription
Explicit interface implemetationPrivate methodICollection.CopyToCopies the entire ReadOnlyCollectionBase to a compatible one-dimensional Array, starting at the specified index of the target array. (Inherited from ReadOnlyCollectionBase.)
Explicit interface implemetationPrivate propertyICollection.IsSynchronizedGets a value indicating whether access to a ReadOnlyCollectionBase object is synchronized (thread safe). (Inherited from ReadOnlyCollectionBase.)
Explicit interface implemetationPrivate propertyICollection.SyncRootGets an object that can be used to synchronize access to a ReadOnlyCollectionBase object. (Inherited from ReadOnlyCollectionBase.)
Top

ASP.NET health monitoring allows production and operations staff to manage deployed Web applications. The System.Web.Management namespace contains the health event types responsible for packaging application health-status data and the provider types responsible for processing this data. It also contains supporting types that help during the management of health events.

The WebBaseEventCollection class is used to deliver a collection of health-monitoring events to providers such as the SqlWebEventProvider.

The following code example shows how to use the WebBaseEventCollection class.


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;

        }

    }
}

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Show:
© 2014 Microsoft