ActivityValidator Klasa

Definicja

Przestroga

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

Pochodna DependencyObjectValidator tego jest klasą bazową dla wszystkich składników modułu sprawdzania poprawności działań.

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
Dziedziczenie
Pochodne
Atrybuty

Przykłady

W poniższym przykładzie przedstawiono kompletny ActivityValidator element używany do działania niestandardowego. Działanie niestandardowe to ConsoleWriteLineActivity działanie, które ma jedną właściwość zależności o nazwie Msg typu String. Moduł sprawdzania poprawności gwarantuje, że właściwość jest ustawiona Msg . Jeśli nie jest ustawiona, kompilator wyświetla błąd, gdy Validate metoda jest wywoływana w obiekcie ActivityValidator , a kompilacja kończy się niepowodzeniem.

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

Uwagi

Uwaga

W tym materiale omówiono przestarzałe typy i przestrzenie nazw. Aby uzyskać więcej informacji, zobacz przestarzałe typy w Windows Workflow Foundation 4,5.

Konstruktory

ActivityValidator()

Inicjuje nowe wystąpienie klasy ActivityValidator.

Metody

Equals(Object)

Określa, czy dany obiekt jest taki sam, jak bieżący obiekt.

(Odziedziczone po Object)
GetFullPropertyName(ValidationManager)

Metoda pomocnika do wyodrębnienia pełnej nazwy właściwości.

(Odziedziczone po Validator)
GetHashCode()

Służy jako domyślna funkcja skrótu.

(Odziedziczone po Object)
GetType()

Type Pobiera wartość bieżącego wystąpienia.

(Odziedziczone po Object)
MemberwiseClone()

Tworzy płytkią kopię bieżącego Objectelementu .

(Odziedziczone po Object)
ToString()

Zwraca ciąg reprezentujący bieżący obiekt.

(Odziedziczone po Object)
Validate(ValidationManager, Object)

Sprawdza, czy podane działanie jest prawidłowe.

ValidateActivityChange(Activity, ActivityChangeAction)

Gdy jest zastępowany w klasie pochodnej, sprawdza poprawność zmiany na podstawie dodanego Activity lub usuniętego elementu. Ta funkcja jest wywoływana podczas stosowania zmian wprowadzonych w przepływie pracy podczas aktualizacji dynamicznych.

(Odziedziczone po Validator)
ValidateProperties(ValidationManager, Object)

Metoda pomocnika, która automatycznie sprawdza poprawność określonych właściwości obiektów.

(Odziedziczone po Validator)
ValidateProperty(PropertyInfo, Object, Object, ValidationManager)

Wykonuje walidację właściwości i zwraca wartość zawierającą ValidationErrorCollection wyniki tej walidacji.

(Odziedziczone po Validator)

Dotyczy