Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

RuleValidation Class

Validates expression conditions.

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

Namespace:  System.Workflow.Activities.Rules
Assembly:  System.Workflow.Activities (in System.Workflow.Activities.dll)
'Declaration
Public Class RuleValidation

The RuleValidation type exposes the following members.

  NameDescription
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.
Top
  NameDescription
Public propertyErrorsGets the errors associated with the RuleValidation.
Public propertyThisTypeGets the type of object.
Top
  NameDescription
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 the default hash function. (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.)
Top

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

Supported in: 4.5.1, 4.5, 4, 3.5, 3.0

Windows Phone 8.1, Windows Phone 8, Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

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.
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.