This documentation is archived and is not being maintained.

RuleValidation Class

Validates expression conditions.


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

public class RuleValidation

The RuleValidation type exposes the following members.

Public methodRuleValidation(Type, ITypeProvider)Initializes a new instance of the RuleValidation class using the Type of the Rule.
Public methodRuleValidation(Activity, ITypeProvider, Boolean)Initializes a new instance of the RuleValidation class using the specified Activity and the type provider.

Public propertyErrorsGets the errors associated with the RuleValidation.
Public propertyThisTypeGets the type of object.

Public methodEquals(Object)Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Public methodExpressionInfoDetermines the type of the code expression.
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public methodGetHashCodeServes as a hash function for a particular type. (Inherited from Object.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodPopParentExpressionRemoves and returns the parent expressions at the top of the Stack.
Public methodPushParentExpressionInserts an object at the top of the Stack.
Public methodToStringReturns 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)

Running this code produces the following error:

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

.NET Framework

Supported in: 4, 3.5, 3.0

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

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