TypeCodeDomSerializer.Serialize Method
Serializes the object root by creating a new type declaration that defines root.
Assembly: System.Design (in System.Design.dll)
public virtual CodeTypeDeclaration Serialize( IDesignerSerializationManager manager, Object root, ICollection members )
Parameters
- manager
- Type: System.ComponentModel.Design.Serialization.IDesignerSerializationManager
The serialization manager to use for serialization.
- root
- Type: System.Object
The object to serialize.
- members
- Type: System.Collections.ICollection
Optional collection of members. Can be null or empty.
Return Value
Type: System.CodeDom.CodeTypeDeclarationA CodeTypeDeclaration that defines the root object.
| Exception | Condition |
|---|---|
| ArgumentNullException |
manager or root is null. |
The Serialize method serializes the given root object and optional collection of members to create a new type definition. If the members collection contains values, these values are serialized. Values themselves may serialize as either member variables or local variables. This determination is done by searching for an extender property on the object called GenerateMember. If true, a member is generated. Otherwise, a local variable is generated. For convenience, the members collection can contain the root object. In this case, the root object is not also added as a member or local variable.
The name of the returned type is taken from the root object’s name, if it was a named object. If not, a name is fabricated from the simple type name of the root class.
The following table shows the tasks performed by the default implementation of the Serialize method.
|
Task |
Description |
|---|---|
|
Context Seeding |
The serialization context is initialized with data including the RootContext and CodeTypeDeclaration |
|
Member Serialization |
Next, Serialize walks all of the members and calls SerializeToExpression. Because serialization is done opportunistically in SerializeToExpression, this ensures that serialization is not done twice. |
|
Root Serialization |
Next, the root object is serialized and its statements are added to the statement collection. |
|
Statement Integration |
After all objects are serialized, the Serialize method orders the statements and adds them to a method returned from GetInitializeMethod. Finally, a constructor is fabricated that calls all of the methods returned from GetInitializeMethod. |
The following table shows the objects the Serialize method places on the context stack.
|
Instance |
Description |
|---|---|
|
This serializer. Deriving classes may find it useful to add public properties to this class. |
|
|
The type being created. Most objects do not need direct access to this. |
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.