ActivityValidator Clase

Definición

Precaución

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

Derivado de DependencyObjectValidator que es una clase base para todos los componentes de validador de actividad.

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
Herencia
Derivado
Atributos

Ejemplos

En el ejemplo siguiente se muestra un ActivityValidator completo utilizado para una actividad personalizada. La actividad personalizada es una actividad ConsoleWriteLineActivity que tiene una propiedad de dependencia única denominada Msg del tipo String. El validador asegura que la propiedad Msg está establecida. Si no está establecida, el compilador muestra un error cuando se llama al método Validate en ActivityValidator y se produce un error en la compilación.

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

Comentarios

Nota

En esta documentación se describen los tipos y espacios de nombres que están obsoletos. Para obtener más información, vea Tipos en desuso en Windows Workflow Foundation 4.5.

Constructores

ActivityValidator()

Inicializa una nueva instancia de la clase ActivityValidator.

Métodos

Equals(Object)

Determina si el objeto especificado es igual que el objeto actual.

(Heredado de Object)
GetFullPropertyName(ValidationManager)

método del asistente para extraer el nombre completo de la propiedad.

(Heredado de Validator)
GetHashCode()

Sirve como la función hash predeterminada.

(Heredado de Object)
GetType()

Obtiene el Type de la instancia actual.

(Heredado de Object)
MemberwiseClone()

Crea una copia superficial del Object actual.

(Heredado de Object)
ToString()

Devuelve una cadena que representa el objeto actual.

(Heredado de Object)
Validate(ValidationManager, Object)

Comprueba que la actividad determinada sea válida.

ValidateActivityChange(Activity, ActivityChangeAction)

Cuando se invalida en una clase derivada, se valida un cambio basado en un Activity específico agregado o eliminado. Esta función se llama durante la aplicación de cambios que se realizan en el flujo de trabajo durante las actualizaciones dinámicas.

(Heredado de Validator)
ValidateProperties(ValidationManager, Object)

método del asistente para validar automáticamente propiedades específicas de objetos.

(Heredado de Validator)
ValidateProperty(PropertyInfo, Object, Object, ValidationManager)

Realiza la validación en una propiedad y devuelve ValidationErrorCollection que contiene los resultados de esa validación.

(Heredado de Validator)

Se aplica a