RuleValidation 类
定义
验证表达式条件。Validates expression conditions.
public ref class RuleValidation
public class RuleValidation
type RuleValidation = class
Public Class RuleValidation
- 继承
-
RuleValidation
示例
下面的代码创建无效的条件。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".
构造函数
| RuleValidation(Activity, ITypeProvider, Boolean) |
使用指定的 RuleValidation 和类型提供程序初始化 Activity 类的新实例。Initializes a new instance of the RuleValidation class using the specified Activity and the type provider. |
| RuleValidation(Type, ITypeProvider) |
使用 RuleValidation 的 Type 初始化 Rule 类的新实例。Initializes a new instance of the RuleValidation class using the Type of the Rule. |
属性
| Errors |
获取与 RuleValidation 相关联的错误。Gets the errors associated with the RuleValidation. |
| ThisType |
获取对象的类型。Gets the type of object. |
方法
| Equals(Object) |
确定指定对象是否等于当前对象。Determines whether the specified object is equal to the current object. (继承自 Object) |
| ExpressionInfo(CodeExpression) |
确定代码表达式的类型。Determines the type of the code expression. |
| GetHashCode() |
作为默认哈希函数。Serves as the default hash function. (继承自 Object) |
| GetType() |
获取当前实例的 Type。Gets the Type of the current instance. (继承自 Object) |
| MemberwiseClone() |
创建当前 Object 的浅表副本。Creates a shallow copy of the current Object. (继承自 Object) |
| PopParentExpression() |
移除并返回位于 Stack 顶部的父表达式。Removes and returns the parent expressions at the top of the Stack. |
| PushParentExpression(CodeExpression) |
在 Stack 的顶部插入一个对象。Inserts an object at the top of the Stack. |
| ToString() |
返回表示当前对象的字符串。Returns a string that represents the current object. (继承自 Object) |