RuleValidation Class

 

Validates expression conditions.

Namespace:   System.Workflow.Activities.Rules
Assembly:  System.Workflow.Activities (in System.Workflow.Activities.dll)

System::Object
  System.Workflow.Activities.Rules::RuleValidation

public ref class RuleValidation 

NameDescription
System_CAPS_pubmethodRuleValidation(Activity^, ITypeProvider^, Boolean)

Initializes a new instance of the RuleValidation class using the specified Activity and the type provider.

System_CAPS_pubmethodRuleValidation(Type^, ITypeProvider^)

Initializes a new instance of the RuleValidation class using the Type of the Rule.

NameDescription
System_CAPS_pubpropertyErrors

Gets the errors associated with the RuleValidation.

System_CAPS_pubpropertyThisType

Gets the type of object.

NameDescription
System_CAPS_pubmethodEquals(Object^)

Determines whether the specified object is equal to the current object.(Inherited from Object.)

System_CAPS_pubmethodExpressionInfo(CodeExpression^)

Determines the type of the code expression.

System_CAPS_protmethodFinalize()

Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.(Inherited from Object.)

System_CAPS_pubmethodGetHashCode()

Serves as the default hash function. (Inherited from Object.)

System_CAPS_pubmethodGetType()

Gets the Type of the current instance.(Inherited from Object.)

System_CAPS_protmethodMemberwiseClone()

Creates a shallow copy of the current Object.(Inherited from Object.)

System_CAPS_pubmethodPopParentExpression()

Removes and returns the parent expressions at the top of the Stack.

System_CAPS_pubmethodPushParentExpression(CodeExpression^)

Inserts an object at the top of the Stack.

System_CAPS_pubmethodToString()

Returns a string that represents the current object.(Inherited from Object.)

The following code creates an invalid condition. It then attempts to validate the condition, and displays any errors that result.

// Create an invalid condition ("abc" < true).
CodeBinaryOperatorExpression invalidCompare = new CodeBinaryOperatorExpression();
invalidCompare.Left = new CodePrimitiveExpression("abc");
invalidCompare.Operator = CodeBinaryOperatorType.LessThan;
invalidCompare.Right = new CodePrimitiveExpression(true);
RuleExpressionCondition condition = new RuleExpressionCondition();
condition.Expression = invalidCompare;

// Create a validator for this condition.
// We are not using "this" in the condition, so the type is not used.
RuleValidation validation = new RuleValidation(this.GetType(), null);

// See whether the condition validates.
if (!condition.Validate(validation))
{
    // There were errors, so display them.
    foreach (ValidationError error in validation.Errors)
    {
        Console.WriteLine(error.ErrorText);
    }
}

Running this code produces the following error:

Relational operator "LessThan" cannot be used on operands of types "string" and "bool".

.NET Framework
Available since 3.0

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

Return to top
Show: