RuleFiringRecord 类

定义

表示从 WebManagementEvent 类派生并实现 IWebEventCustomEvaluator 接口的事件的激发记录。

public ref class RuleFiringRecord sealed
public sealed class RuleFiringRecord
type RuleFiringRecord = class
Public NotInheritable Class RuleFiringRecord
继承
RuleFiringRecord

示例

下面的代码示例演示如何 RuleFiringRecord 在传递给 CanFire 方法时使用 。

// Implements the IWebEventCustomEvaluator.CanFire 
// method. It is called by the ASP.NET if this custom
// type is configured in the profile
// element of the healthMonitoring section.
public bool CanFire(
    System.Web.Management.WebBaseEvent e, 
    RuleFiringRecord rule)
{

    bool fireEvent;
    string lastFired = rule.LastFired.ToString();
    string timesRaised = rule.TimesRaised.ToString();

    // Fire every other event raised.
    fireEvent =
        (rule.TimesRaised % 2 == 0) ? true : false;

    if (fireEvent)
    {
        firingRecordInfo =
            string.Format("Event last fired: {0}",
            lastFired) +
            string.Format(". Times raised: {0}",
            timesRaised);
    }
    else
        firingRecordInfo =
          string.Format(
           "Event not fired. Times raised: {0}",
           timesRaised);

    return fireEvent;
}
' Implements the IWebEventCustomEvaluator.CanFire 
' method. It is called by the ASP.NET if this custom
' type is configured in the profile
' element of the healthMonitoring section.
Public Function CanFire( _
ByVal e As System.Web.Management.WebBaseEvent, _
ByVal rule As RuleFiringRecord) As Boolean _
Implements System.Web.Management.IWebEventCustomEvaluator.CanFire

    Dim fireEvent As Boolean
    Dim lastFired As String = _
        rule.LastFired.ToString()
    Dim timesRaised As String = _
        rule.TimesRaised.ToString()

    ' Fire every other event raised.
    fireEvent = _
    IIf(rule.TimesRaised Mod 2 = 0, True, False)

    If fireEvent Then
        firingRecordInfo = String.Format( _
        "Event last fired: {0}", lastFired) + _
        String.Format( _
        ". Times raised: {0}",  timesRaised) 
      
    Else
        firingRecordInfo = String.Format( _
        "Event not fired. Times raised: {0}", _
        timesRaised)
    End If

    Return fireEvent

End Function 'CanFire

注解

RuleFiringRecord 提供的信息可用于确定是否应记录事件的触发。

属性

LastFired

获取事件上次激发的时间。

TimesRaised

获取事件的总引发次数。

方法

Equals(Object)

确定指定对象是否等于当前对象。

(继承自 Object)
GetHashCode()

作为默认哈希函数。

(继承自 Object)
GetType()

获取当前实例的 Type

(继承自 Object)
MemberwiseClone()

创建当前 Object 的浅表副本。

(继承自 Object)
ToString()

返回表示当前对象的字符串。

(继承自 Object)

适用于