CodeDomSerializerBase.SerializeToExpression Method (IDesignerSerializationManager, Object)
Serializes the given object into an expression.
Assembly: System.Design (in System.Design.dll)
protected CodeExpression SerializeToExpression( IDesignerSerializationManager manager, object value )
The IDesignerSerializationManager to use for serialization.
The object to serialize. Can be null.
The value parameter can be null, in which case a primitive expression will be returned.
Themethod uses the following rules for serializing types:
It first calls the GetExpression method to see if an expression has already been created for the object. If so, it returns the existing expression.
It then locates the object’s serializer, and asks it to serialize.
If the return value of the object’s serializer is a CodeExpression, the expression is returned.
It makes one last call to GetExpression to see if the serializer added an expression.
Finally, it returns null.
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 StatementContext on the context stack and add statements to the statement context object's StatementCollection property. If there is no statement context, the method will look in the context for a CodeStatementCollection and add the statements there. If no place can be found to add the statements, an error will be generated.method will first look for a
Available since 2.0