ActivityValidator ActivityValidator ActivityValidator ActivityValidator Class

Definición

Advertencia

Esta API está ya obsoleta.

Derivado de DependencyObjectValidator que es una clase base para todos los componentes de validador de actividad.Derivative of DependencyObjectValidator that is a base class for all activity validator components.

public ref 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
Public Class ActivityValidator
Inherits DependencyObjectValidator
Herencia
Derivado
Atributos

Ejemplos

En el ejemplo siguiente se muestra un ActivityValidator completo utilizado para una actividad personalizada.The following example shows a complete ActivityValidator used for a custom activity. La actividad personalizada es una actividad ConsoleWriteLineActivity que tiene una propiedad de dependencia única denominada Msg del tipo String.The custom activity is a ConsoleWriteLineActivity activity that has a single dependency property named Msg of type String. El validador asegura que la propiedad Msg está establecida.The validator ensures that the Msg property is set. 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.If it is not set, the compiler displays an error when the Validate method is called on the ActivityValidator and the compilation fails.

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.This material discusses types and namespaces that are obsolete. Para obtener más información, vea Tipos en desuso en Windows Workflow Foundation 4.5.For more information, see Deprecated Types in Windows Workflow Foundation 4.5.

Constructores

ActivityValidator() ActivityValidator() ActivityValidator() ActivityValidator()

Inicializa una nueva instancia de la clase ActivityValidator.Initializes a new instance of the ActivityValidator class.

Métodos

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

Determina si el objeto especificado es igual al objeto actual.Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetFullPropertyName(ValidationManager) GetFullPropertyName(ValidationManager) GetFullPropertyName(ValidationManager) GetFullPropertyName(ValidationManager)

método del asistente para extraer el nombre completo de la propiedad.Helper method to extract the full property name.

(Inherited from Validator)
GetHashCode() GetHashCode() GetHashCode() GetHashCode()

Sirve como la función hash predeterminada.Serves as the default hash function.

(Inherited from Object)
GetType() GetType() GetType() GetType()

Obtiene el Type de la instancia actual.Gets the Type of the current instance.

(Inherited from Object)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

Crea una copia superficial del objeto Object actual.Creates a shallow copy of the current Object.

(Inherited from Object)
ToString() ToString() ToString() ToString()

Devuelve una cadena que representa el objeto actual.Returns a string that represents the current object.

(Inherited from Object)
Validate(ValidationManager, Object) Validate(ValidationManager, Object) Validate(ValidationManager, Object) Validate(ValidationManager, Object)

Comprueba que la actividad determinada sea válida.Verifies that the given activity is valid.

ValidateActivityChange(Activity, ActivityChangeAction) ValidateActivityChange(Activity, ActivityChangeAction) ValidateActivityChange(Activity, ActivityChangeAction) ValidateActivityChange(Activity, ActivityChangeAction)

Cuando se invalida en una clase derivada, se valida un cambio basado en un Activity específico agregado o eliminado.When overridden in a derived class, validates a change based on a specified Activity being added or removed. Esta función se llama durante la aplicación de cambios que se realizan en el flujo de trabajo durante las actualizaciones dinámicas.This function is called during the application of changes that are made to the workflow during dynamic updates.

(Inherited from Validator)
ValidateProperties(ValidationManager, Object) ValidateProperties(ValidationManager, Object) ValidateProperties(ValidationManager, Object) ValidateProperties(ValidationManager, Object)

método del asistente para validar automáticamente propiedades específicas de objetos.Helper method to automatically validate the specific objects properties.

(Inherited from Validator)
ValidateProperty(PropertyInfo, Object, Object, ValidationManager) ValidateProperty(PropertyInfo, Object, Object, ValidationManager) ValidateProperty(PropertyInfo, Object, Object, ValidationManager) ValidateProperty(PropertyInfo, Object, Object, ValidationManager)

Realiza la validación en una propiedad y devuelve ValidationErrorCollection que contiene los resultados de esa validación.Performs validation on a property and returns a ValidationErrorCollection that contains the results of that validation.

(Inherited from Validator)

Se aplica a