CodeDomSerializerBase.SerializeToResourceExpression Method (IDesignerSerializationManager, Object)


The .NET API Reference documentation has a new home. Visit the .NET API Browser on to see the new experience.

Serializes the given object into an expression.

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

protected CodeExpression SerializeToResourceExpression(
	IDesignerSerializationManager manager,
	object value


Type: System.ComponentModel.Design.Serialization.IDesignerSerializationManager

The IDesignerSerializationManager to use for serialization.

Type: System.Object

The object to serialize.

Return Value

Type: System.CodeDom.CodeExpression

A CodeExpression containing value as a serialized expression.

Exception Condition

manager is null.

The SerializeToResourceExpression method is a helper method that serializes a value to a resource expression. This is in contrast to the SerializeResource method, which writes a value to a resource binary object. SerializeToResourceExpression goes one step further and returns an expression that can be used to recover the resource. For example, the return value might be "rm.GetValue("SomeBitmap");". The name of the resource is calculated from the ExpressionContext, if one can be found on the context stack.

The SerializeToResourceExpression method will look on the ContextStack for the following objects:

  • CodeStatementCollection—a collection of statements to add a resource manager to, if one needs to be declared.

  • RootContext—the root expression, which is needed to create a resource manager.

  • ExpressionContext—used to fabricate a name for the resource and to decide what type of resource manager call to make.

.NET Framework
Available since 2.0
Return to top