本文整理汇总了C#中System.Web.Management.WebBaseEventCollection类的典型用法代码示例。如果您正苦于以下问题:C# WebBaseEventCollection类的具体用法?C# WebBaseEventCollection怎么用?C# WebBaseEventCollection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
WebBaseEventCollection类属于System.Web.Management命名空间,在下文中一共展示了WebBaseEventCollection类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ArrayList
//引入命名空间
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;
}
}
}