Export (0) Print
Expand All

ExpressionContext Class

Provides a means of passing context state among serializers. This class cannot be inherited.

System.Object
  System.ComponentModel.Design.Serialization.ExpressionContext

Namespace:  System.ComponentModel.Design.Serialization
Assembly:  System.Design (in System.Design.dll)

'Declaration
Public NotInheritable Class ExpressionContext

The ExpressionContext type exposes the following members.

  NameDescription
Public methodExpressionContext(CodeExpression, Type, Object)Initializes a new instance of the ExpressionContext class with the given expression and owner.
Public methodExpressionContext(CodeExpression, Type, Object, Object)Initializes a new instance of the ExpressionContext class with a current value.
Top

  NameDescription
Public propertyExpressionGets the expression this context represents.
Public propertyExpressionTypeGets the Type of the expression.
Public propertyOwnerGets the object owning this expression.
Public propertyPresetValueGets the preset value of an expression.
Top

  NameDescription
Public methodEquals(Object)Determines whether the specified object is equal to the current object. (Inherited from Object.)
Public methodGetHashCodeServes as the default hash function. (Inherited from Object.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)
Top

An ExpressionContext is placed on the context stack and contains the most relevant expression during serialization. The following C# code demonstrates an assignment.

button1.Text = "Hello";

During serialization, several serializers are responsible for creating this single statement. 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. 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. 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.

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4, 3.5, 3.0, 2.0

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Show:
© 2014 Microsoft