ActivityValidator Class

Derivative of DependencyObjectValidator that is a base class for all activity validator components.

Namespace: System.Workflow.ComponentModel.Compiler
Assembly: System.Workflow.ComponentModel (in system.workflow.componentmodel.dll)

public class ActivityValidator : DependencyObjectValidator
public class ActivityValidator extends DependencyObjectValidator
public class ActivityValidator extends DependencyObjectValidator
Not applicable.

The following example shows a complete ActivityValidator used for a custom activity. The validator enforces a parent child relationship rule in that the custom activity cannot be used as a child activity of the ListenActivity. When this occurs, the compiler will display an error when the Validate method is called on the ActivityValidator and the compilation will fail.

internal sealed class CustomActivityValidator : ActivityValidator
{
    public override ValidationErrorCollection Validate(ValidationManager manager, object obj)
    {
        ValidationErrorCollection validationErrors = base.Validate(manager, obj);

        CustomActivity ca = obj as CustomActivity;
        if (ca == null)
            throw new ArgumentException("Activity instance is null", typeof(CustomActivity).FullName);

        Activity parent = ca.Parent;
        while (parent != null)
        {
            if (parent is ListenActivity)
            {
                validationErrors.Add(new ValidationError("Cannot add custom activity to ListenActivity", 1));
                break;
            }
            parent = parent.Parent;
        }
        return validationErrors;
    }
}

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0

Community Additions

ADD
Show: