Share via


PositiveTimeSpanValidator.CanValidate(Type) メソッド

定義

オブジェクトの型が検証可能かどうかを判断します。

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

パラメーター

type
Type

オブジェクトの型。

戻り値

type パラメーターが TimeSpan オブジェクトと一致する場合は true。それ以外の場合は false

次のコード例は、CanValidate メソッドの使用方法を示します。 このコード例は、PositiveTimeSpanValidator クラスのために提供されている大規模な例の一部です。

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

適用対象