ActivityValidator クラス

定義

注意事項

The System.Workflow.* types are deprecated. Instead, please use the new types from System.Activities.*

アクティビティ バリデーター コンポーネントすべての基本クラスである、DependencyObjectValidator の派生クラス。

public ref class ActivityValidator : System::Workflow::ComponentModel::Compiler::DependencyObjectValidator
public class ActivityValidator : System.Workflow.ComponentModel.Compiler.DependencyObjectValidator
[System.Obsolete("The System.Workflow.* types are deprecated.  Instead, please use the new types from System.Activities.*")]
public class ActivityValidator : System.Workflow.ComponentModel.Compiler.DependencyObjectValidator
type ActivityValidator = class
    inherit DependencyObjectValidator
[<System.Obsolete("The System.Workflow.* types are deprecated.  Instead, please use the new types from System.Activities.*")>]
type ActivityValidator = class
    inherit DependencyObjectValidator
Public Class ActivityValidator
Inherits DependencyObjectValidator
継承
派生
属性

カスタム アクティビティに対して使う、完全な ActivityValidator の例を次に示します。 カスタム アクティビティは、ConsoleWriteLineActivity 型の Msg という名前の単一の依存関係プロパティが含まれる String アクティビティです。 バリデーターによって Msg プロパティが設定されます。 設定されていない場合、ValidateActivityValidator メソッドが呼び出された時点でエラーが表示され、コンパイルは失敗します。

class ConsoleWriteLineActivityValidator : ActivityValidator
{
    public override ValidationErrorCollection Validate(ValidationManager manager, object obj)
    {
        // Invoke the base class method implementation to
        // perform default validation.
        ValidationErrorCollection errors = base.Validate(manager, obj);

        // Make sure there is an activity instance.
        ConsoleWriteLineActivity crw = obj as ConsoleWriteLineActivity;
        if (crw == null)
        {
            throw new InvalidOperationException();
        }

        // If the activity has no parent then this validation
        // is occurring during the compilation of the activity
        // and not during the hosting or creation of an
        // activity instance.
        if (crw.Parent == null)
        {
            // Can skip the rest of the validation because
            // it deals with the hosting and the creation
            // of the activity.
            return errors;
        }

        // Msg is required. Add a validation error if there is no
        // Msg specified or Msg is not bound to another property.
        if (string.IsNullOrEmpty(crw.Msg) &&
            crw.GetBinding(ConsoleWriteLineActivity.MsgProperty) == null)
        {
            errors.Add(new ValidationError("Msg is required", 100, false, "Msg"));
        }

        return errors;
    }
}
Class ConsoleWriteLineActivityValidator
    Inherits ActivityValidator

    Public Overrides Function Validate( _
        ByVal manager As System.Workflow.ComponentModel.Compiler.ValidationManager, _
        ByVal obj As Object) As System.Workflow.ComponentModel.Compiler.ValidationErrorCollection

        'Invoke the base class method implementation to
        'perform default validation.
        Dim errors As ValidationErrorCollection = MyBase.Validate(manager, obj)

        'Make sure there is an activity instance.
        Dim crw As ConsoleWriteLineActivity = CType(obj, ConsoleWriteLineActivity)
        If crw Is Nothing Then
            Throw New InvalidOperationException()
        End If

        'If the activity has no parent then this validation
        'is occurring during the compilation of the activity
        'and not during the hosting or creation of an
        'activity instance.
        If crw.Parent Is Nothing Then
            'Can skip the rest of the validation because
            'it deals with the hosting and the creation
            'of the activity.
            Return errors
        End If

        'Msg is required. Add a validation error if there is no
        'Msg specified or Msg is not bound to another property.
        If String.IsNullOrEmpty(crw.Msg) And _
            crw.GetBinding(ConsoleWriteLineActivity.MsgProperty) Is Nothing Then

            errors.Add(New ValidationError("Msg is required", 100, False, "Msg"))

        End If

        Return errors
    End Function
End Class

注釈

注意

ここでは、廃止された型と名前空間について説明します。 詳細については、「.NET 4.5 での Windows Workflow Foundation の新機能」を参照してください。

コンストラクター

ActivityValidator()

ActivityValidator クラスの新しいインスタンスを初期化します。

メソッド

Equals(Object)

指定されたオブジェクトが現在のオブジェクトと等しいかどうかを判断します。

(継承元 Object)
GetFullPropertyName(ValidationManager)

プロパティの完全名を抽出するヘルパー メソッド。

(継承元 Validator)
GetHashCode()

既定のハッシュ関数として機能します。

(継承元 Object)
GetType()

現在のインスタンスの Type を取得します。

(継承元 Object)
MemberwiseClone()

現在の Object の簡易コピーを作成します。

(継承元 Object)
ToString()

現在のオブジェクトを表す文字列を返します。

(継承元 Object)
Validate(ValidationManager, Object)

指定されたアクティビティが有効であることを検証します。

ValidateActivityChange(Activity, ActivityChangeAction)

派生クラスでオーバーライドすると、追加または削除された指定の Activity を基に変更内容を検証します。 動的更新の際、ワークフローに変更を施す時点で呼び出されます。

(継承元 Validator)
ValidateProperties(ValidationManager, Object)

特定のオブジェクト プロパティを自動的に検証するヘルパー メソッド。

(継承元 Validator)
ValidateProperty(PropertyInfo, Object, Object, ValidationManager)

プロパティを検証し、その結果を格納した ValidationErrorCollection を返します。

(継承元 Validator)

適用対象