IWebEventCustomEvaluator.CanFire(WebBaseEvent, RuleFiringRecord) Méthode
Définition
Important
Certaines informations portent sur la préversion du produit qui est susceptible d’être en grande partie modifiée avant sa publication. Microsoft exclut toute garantie, expresse ou implicite, concernant les informations fournies ici.
Évalue si un événement doit être déclenché.
public:
bool CanFire(System::Web::Management::WebBaseEvent ^ raisedEvent, System::Web::Management::RuleFiringRecord ^ record);
public bool CanFire (System.Web.Management.WebBaseEvent raisedEvent, System.Web.Management.RuleFiringRecord record);
abstract member CanFire : System.Web.Management.WebBaseEvent * System.Web.Management.RuleFiringRecord -> bool
Public Function CanFire (raisedEvent As WebBaseEvent, record As RuleFiringRecord) As Boolean
Paramètres
- raisedEvent
- WebBaseEvent
Événement à déclencher.
- record
- RuleFiringRecord
RuleFiringRecord contenant les informations sur l'événement.
Retours
true
si l'événement doit être déclenché ; sinon, false
.
Exemples
L’exemple de code suivant montre une implémentation personnalisée de la CanFire méthode.
// 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
Remarques
Si l’évaluateur d’événement personnalisé retourne true
, l’événement est déclenché, puis traité par le fournisseur associé.