This documentation is archived and is not being maintained.

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

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

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

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0, 1.1, 1.0
Show: