RuleValidation 類別
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
驗證表現條件。
public ref class RuleValidation
public class RuleValidation
type RuleValidation = class
Public Class RuleValidation
- 繼承
-
RuleValidation
範例
以下程式碼會產生一個無效條件。 接著嘗試驗證條件,並顯示產生的錯誤。
// 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);
}
}
執行此程式碼會產生以下錯誤:
Relational operator "LessThan" cannot be used on operands of types "string" and "bool".
建構函式
| 名稱 | Description |
|---|---|
| RuleValidation(Activity, ITypeProvider, Boolean) |
使用指定的 RuleValidation Config 和型別提供者初始化該類別的新實例Activity。 |
| RuleValidation(Type, ITypeProvider) |
利用 RuleValidation 的 Type初始化類別的新Rule實例。 |
屬性
| 名稱 | Description |
|---|---|
| Errors |
會產生與 RuleValidation相關的錯誤。 |
| ThisType |
能理解物品的類型。 |
方法
| 名稱 | Description |
|---|---|
| Equals(Object) |
判斷指定的物件是否等於目前的物件。 (繼承來源 Object) |
| ExpressionInfo(CodeExpression) |
決定碼表達式的類型。 |
| GetHashCode() |
做為預設哈希函式。 (繼承來源 Object) |
| GetType() |
取得目前實例的 Type。 (繼承來源 Object) |
| MemberwiseClone() |
建立目前 Object的淺層複本。 (繼承來源 Object) |
| PopParentExpression() |
移除並回傳位於 Stack頂部的父表達式。 |
| PushParentExpression(CodeExpression) |
在 的頂部 Stack插入一個物件。 |
| ToString() |
傳回表示目前 物件的字串。 (繼承來源 Object) |