IDesignerSerializationManager Interface

Provides an interface that can manage design-time serialization.

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

'Declaration
Public Interface IDesignerSerializationManager
	Inherits IServiceProvider
'Usage
Dim instance As IDesignerSerializationManager

public interface IDesignerSerializationManager extends IServiceProvider
public interface IDesignerSerializationManager extends IServiceProvider
Not applicable.

A designer can utilize IDesignerSerializationManager to access services useful to managing design-time serialization processes. For example, a class that implements the designer serialization manager can use this interface to create objects, look up types, identify objects, and customize the serialization of particular types.

The following example illustrates how to use IDesignerSerializationManager to serialize and deserialize Code DOM statements.

Imports System
Imports System.CodeDom
Imports System.ComponentModel
Imports System.ComponentModel.Design
Imports System.ComponentModel.Design.Serialization
Imports System.Drawing
Imports System.Windows.Forms

Namespace CodeDomSerializerSample
   Friend Class MyCodeDomSerializer
      Inherits CodeDomSerializer

      Public Overrides Function Deserialize(ByVal manager As IDesignerSerializationManager, _
                                                ByVal codeObject As Object) As Object
         ' This is how we associate the component with the serializer.
         Dim baseClassSerializer As CodeDomSerializer = CType(manager.GetSerializer( _
                GetType(MyComponent).BaseType, GetType(CodeDomSerializer)), CodeDomSerializer)

         ' This is the simplest case, in which the class just calls the base class
         '  to do the work. 
         Return baseClassSerializer.Deserialize(manager, codeObject)
      End Function 'Deserialize

      Public Overrides Function Serialize(ByVal manager As IDesignerSerializationManager, _
                                            ByVal value As Object) As Object
         ' Associate the component with the serializer in the same manner as with
         '  Deserialize
         Dim baseClassSerializer As CodeDomSerializer = CType(manager.GetSerializer( _
                GetType(MyComponent).BaseType, GetType(CodeDomSerializer)), CodeDomSerializer)

         Dim codeObject As Object = baseClassSerializer.Serialize(manager, value)

         ' Anything could be in the codeObject.  This sample operates on a
         '  CodeStatementCollection.
         If TypeOf codeObject Is CodeStatementCollection Then
            Dim statements As CodeStatementCollection = CType(codeObject, CodeStatementCollection)

            ' The code statement collection is valid, so add a comment.
            Dim commentText As String = "This comment was added to this object by a custom serializer."
            Dim comment As New CodeCommentStatement(commentText)
            statements.Insert(0, comment)
         End If
         Return codeObject
      End Function 'Serialize
   End Class 'MyCodeDomSerializer

   <DesignerSerializer(GetType(MyCodeDomSerializer), GetType(CodeDomSerializer))> _
   Public Class MyComponent
      Inherits Component
      Private localProperty As String = "Component Property Value"

      Public Property LocalProp() As String
         Get
            Return localProperty
         End Get
         Set(ByVal Value As String)
            localProperty = Value
         End Set
      End Property
   End Class 'MyComponent

End Namespace

import System.*;
import System.CodeDom.*;
import System.ComponentModel.*;
import System.ComponentModel.Design.*;
import System.ComponentModel.Design.Serialization.*;
import System.Drawing.*;
import System.Windows.Forms.*;

   
class MyCodeDomSerializer extends CodeDomSerializer
{
    public Object Deserialize(IDesignerSerializationManager manager,
        Object codeObject) {

        // This is how we associate the component with the serializer.
        CodeDomSerializer baseClassSerializer = (CodeDomSerializer)
            manager.GetSerializer(MyComponent.class.ToType().get_BaseType(),
            CodeDomSerializer.class.ToType());
        
        /* This is the simplest case, in which the class just calls the base
            class to do the work. 
         */
         return baseClassSerializer.Deserialize(manager, codeObject);
    } //Deserialize
      
    public Object Serialize(IDesignerSerializationManager manager,
        Object value)
    {
        /* Associate the component with the serializer in the same manner as 
            with Deserialize 
         */

        CodeDomSerializer baseClassSerializer = (CodeDomSerializer)
            manager.GetSerializer(MyComponent.class.ToType().
            get_BaseType(), CodeDomSerializer.class.ToType());
        Object codeObject = baseClassSerializer.Serialize(manager, value);
         
        /* Anything could be in the codeObject.  This sample operates on a
                CodeStatementCollection. 
         */

        if (codeObject instanceof CodeStatementCollection) {
            CodeStatementCollection statements = (CodeStatementCollection)
                codeObject;
             // The code statement collection is valid, so add a comment.
            String commentText = "This comment was added to this object by a "
                + " custom serializer.";
            CodeCommentStatement comment =  new 
                CodeCommentStatement(commentText);
            statements.Insert(0, comment);
        }
         return codeObject;
    } //Serialize
} //MyCodeDomSerializer
      
/** @attribute DesignerSerializer(MyCodeDomSerializer.class,
  CodeDomSerializer.class)
 */

public class MyComponent extends Component
{
    private String localProperty = "Component Property Value";
      
    /** @property 
     */
    public String get_LocalProperty()
    {
        return localProperty;
    } //get_LocalProperty

    /** @property 
     */
    public void set_LocalProperty (String value )
    {
        localProperty = value;
    } //set_LocalProperty
} //MyComponent

Windows 98, Windows Server 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

Community Additions

ADD
Show: