Share via


PositiveTimeSpanValidator.CanValidate(Type) Méthode

Définition

Détermine si le type d’objet peut être validé.

public:
 override bool CanValidate(Type ^ type);
public override bool CanValidate (Type type);
override this.CanValidate : Type -> bool
Public Overrides Function CanValidate (type As Type) As Boolean

Paramètres

type
Type

Type d'objet.

Retours

true si le paramètre type correspond à un objet TimeSpan ; sinon, false.

Exemples

L'exemple de code suivant illustre l'utilisation de la méthode CanValidate. Cet exemple de code fait partie d’un exemple plus grand fourni pour la PositiveTimeSpanValidator classe .

// Determine if the Validator can validate
// the type it contains.
valBase = customValAttr.ValidatorInstance;
if (valBase.CanValidate(resultTimeSpan.GetType()))
{
    // Validate the TimeSpan using a
    // custom PositiveTimeSpanValidator.
    valBase.Validate(resultTimeSpan);
}
' Determine if the Validator can validate
' the type it contains.
valBase = customValAttr.ValidatorInstance
If valBase.CanValidate(resultTimeSpan.GetType()) Then
    ' Validate the TimeSpan using a
    ' custom PositiveTimeSpanValidator.
    valBase.Validate(resultTimeSpan)
End If

S’applique à