IWebEventCustomEvaluator.CanFire Method (WebBaseEvent, RuleFiringRecord)

 

Evaluates whether an event should be raised.

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

Function CanFire (
	raisedEvent As WebBaseEvent,
	record As RuleFiringRecord
) As Boolean

Parameters

raisedEvent
Type: System.Web.Management.WebBaseEvent

The event to raise.

record
Type: System.Web.Management.RuleFiringRecord

The RuleFiringRecord containing information about the event.

Return Value

Type: System.Boolean

true if the event should be raised; otherwise, false.

If the custom event evaluator returns true, the event is raised and then processed by the associated provider.

The following code example shows a custom implementation of 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 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

.NET Framework
Available since 2.0
Return to top
Show: