This documentation is archived and is not being maintained.
RuleValidation Class
Visual Studio 2010
Validates expression conditions.
Assembly: System.Workflow.Activities (in System.Workflow.Activities.dll)
The RuleValidation type exposes the following members.
| Name | Description | |
|---|---|---|
![]() | RuleValidation(Type, ITypeProvider) | Initializes a new instance of the RuleValidation class using the Type of the Rule. |
![]() | RuleValidation(Activity, ITypeProvider, Boolean) | Initializes a new instance of the RuleValidation class using the specified Activity and the type provider. |
| Name | Description | |
|---|---|---|
![]() | Equals(Object) | Determines whether the specified Object is equal to the current Object. (Inherited from Object.) |
![]() | ExpressionInfo | Determines the type of the code expression. |
![]() | Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) |
![]() | GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.) |
![]() | GetType | Gets the Type of the current instance. (Inherited from Object.) |
![]() | MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) |
![]() | PopParentExpression | Removes and returns the parent expressions at the top of the Stack. |
![]() | PushParentExpression | Inserts an object at the top of the Stack. |
![]() | ToString | 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".
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.
Show:
