Επεξεργασία

Κοινή χρήση μέσω


RuleFiringRecord Class

Definition

Represents the firing record for an event that derives from the WebManagementEvent class and implements the IWebEventCustomEvaluator interface.

public ref class RuleFiringRecord sealed
public sealed class RuleFiringRecord
type RuleFiringRecord = class
Public NotInheritable Class RuleFiringRecord
Inheritance
RuleFiringRecord

Examples

The following code example shows how the RuleFiringRecord is used when passed to the CanFire method.

// 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

Remarks

The RuleFiringRecord class provides information that could be used to determine whether the firing of the event should be recorded.

Properties

LastFired

Gets the last time that the event was last fired.

TimesRaised

Gets the total number of times that the event has been raised.

Methods

Equals(Object)

Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetType()

Gets the Type of the current instance.

(Inherited from Object)
MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
ToString()

Returns a string that represents the current object.

(Inherited from Object)

Applies to