System.ComponentModel.Design.Serialization.CodeDomSerializerBase.SerializeToExpression Method

Serializes the given object into an expression.

Syntax

protected System.CodeDom.CodeExpression SerializeToExpression (IDesignerSerializationManager manager, object instance)

Parameters

instance
Documentation for this section has not yet been entered.
manager
The System.ComponentModel.Design.Serialization.IDesignerSerializationManager to use for serialization.

Returns

A System.CodeDom.CodeExpression object if value can be serialized; otherwise, null.

Remarks

The value parameter can be null, in which case a primitive expression will be returned.

The CodeDomSerializerBase.SerializeToExpression(IDesignerSerializationManager, object) method uses the following rules for serializing types:

[The 'ordered' type of list has not been implemented in the ECMA stylesheet.]

If no expression could be created and no suitable serializer could be found, an error will be reported through the serialization manager. No error will be reported if a serializer was found but it failed to produce an expression. In this case, it is assumed that the serializer either already reported the error or it did not attempt to serialize the object.

If the serializer returned a statement or a collection of statements, those statements will not be discarded. The CodeDomSerializerBase.SerializeToExpression(IDesignerSerializationManager, object) method will first look for a System.ComponentModel.Design.Serialization.StatementContext on the context stack and add statements to the statement context object's StatementContext.StatementCollection property. If there is no statement context, the CodeDomSerializerBase.SerializeToExpression(IDesignerSerializationManager, object) method will look in the context for a System.CodeDom.CodeStatementCollection and add the statements there. If no place can be found to add the statements, an error will be generated.

Note:

You should not call the CodeDomSerializerBase.SerializeToExpression(IDesignerSerializationManager, object) method within IDesignerSerializationService.Serialize(ICollection) when serializing your own object. Instead, you should call CodeDomSerializerBase.GetExpression(IDesignerSerializationManager, object). If it returns null, create your own expression and call erload:System.ComponentModel.Design.Serialization.CodeDomSerializerBase.SetExpression. Then proceed with the rest of your serialization.

Requirements

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