RuleValidation Class
.NET Framework 3.0
Validates expression conditions.
Namespace: System.Workflow.Activities.Rules
Assembly: System.Workflow.Activities (in system.workflow.activities.dll)
Assembly: System.Workflow.Activities (in system.workflow.activities.dll)
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 // since we are not using "this" in the condition, the type isn't used RuleValidation validation = new RuleValidation(this.GetType(), null); // see if 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 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.Community Additions
ADD
Show: