ExpressionContext 類別

定義

提供在序列化程式之間傳遞內容狀態的方法。Provides a means of passing context state among serializers. 這個類別無法被繼承。This class cannot be inherited.

public ref class ExpressionContext sealed
public sealed class ExpressionContext
type ExpressionContext = class
Public NotInheritable Class ExpressionContext
繼承
ExpressionContext

備註

ExpressionContext 會放在內容堆疊上,並包含序列化期間最相關的運算式。An ExpressionContext is placed on the context stack and contains the most relevant expression during serialization. 下列C#程式碼示範指派。The following C# code demonstrates an assignment.

button1.Text = "Hello";  

在序列化期間,有數個序列化程式負責建立這個單一語句。During serialization, several serializers are responsible for creating this single statement. 其中一個序列化程式負責建立 "Hello"。One of those serializers is responsible for creating "Hello". 有時候,序列化程式可能需要知道它正在建立其運算式的內容。There are times when that serializer may need to know the context in which it is creating its expression. 在上述範例中,不需要此內容。In the previous example, this context is not needed. 下列C#程式碼顯示需要瞭解內容的情況。The following C# code shows a situation in which knowledge of the context is necessary.

button1.Text = rm.GetString("button1_Text");  

在此情況下,必須通知負責建立資源運算式的序列化程式,以取得目標物件的名稱。In this case, the serializer responsible for creating the resource expression needs to be informed of the names of the target objects. ExpressionContext 類別可以用於這個。The ExpressionContext class can be used for this. 當每個序列化程式建立一個運算式,並叫用序列化程式來處理整個語句的較小部分時,序列化程式會在內容堆疊上推送運算式內容。As each serializer creates an expression and invokes a serializer to handle a smaller part of the statement as a whole, the serializer pushes an expression context on the context stack. 每個運算式內容都有一個父屬性,可在堆疊上尋找下一個運算式內容。Each expression context has a parent property that locates the next expression context on the stack. 這可提供便利的「遍歷」功能。This provides a convenient traversal capability.

建構函式

ExpressionContext(CodeExpression, Type, Object)

使用指定的運算式與擁有者,將新的 ExpressionContext 執行個體初始化。Initializes a new instance of the ExpressionContext class with the given expression and owner.

ExpressionContext(CodeExpression, Type, Object, Object)

使用現有值,將 ExpressionContext 類別的新執行個體初始化。Initializes a new instance of the ExpressionContext class with a current value.

屬性

Expression

取得這個內容表示的運算式。Gets the expression this context represents.

ExpressionType

取得運算式的 TypeGets the Type of the expression.

Owner

取得擁有這個運算式的物件。Gets the object owning this expression.

PresetValue

取得運算式的預設值。Gets the preset value of an expression.

方法

Equals(Object)

判斷指定的物件是否等於目前的物件。Determines whether the specified object is equal to the current object.

(繼承來源 Object)
GetHashCode()

作為預設雜湊函數。Serves as the default hash function.

(繼承來源 Object)
GetType()

取得目前執行個體的 TypeGets the Type of the current instance.

(繼承來源 Object)
MemberwiseClone()

建立目前 Object 的淺層複製。Creates a shallow copy of the current Object.

(繼承來源 Object)
ToString()

傳回代表目前物件的字串。Returns a string that represents the current object.

(繼承來源 Object)

適用於

另請參閱