IDesignerSerializationManager Interface

 

Provides an interface that can manage design-time serialization.

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

public interface class IDesignerSerializationManager : IServiceProvider

NameDescription
System_CAPS_pubpropertyContext

Gets a stack-based, user-defined storage area that is useful for communication between serializers.

System_CAPS_pubpropertyProperties

Indicates custom properties that can be serializable with available serializers.

NameDescription
System_CAPS_pubmethodAddSerializationProvider(IDesignerSerializationProvider^)

Adds the specified serialization provider to the serialization manager.

System_CAPS_pubmethodCreateInstance(Type^, ICollection^, String^, Boolean)

Creates an instance of the specified type and adds it to a collection of named instances.

System_CAPS_pubmethodGetInstance(String^)

Gets an instance of a created object of the specified name, or null if that object does not exist.

System_CAPS_pubmethodGetName(Object^)

Gets the name of the specified object, or null if the object has no name.

System_CAPS_pubmethodGetSerializer(Type^, Type^)

Gets a serializer of the requested type for the specified object type.

System_CAPS_pubmethodGetService(Type^)

Gets the service object of the specified type.(Inherited from IServiceProvider.)

System_CAPS_pubmethodGetType(String^)

Gets a type of the specified name.

System_CAPS_pubmethodRemoveSerializationProvider(IDesignerSerializationProvider^)

Removes a custom serialization provider from the serialization manager.

System_CAPS_pubmethodReportError(Object^)

Reports an error in serialization.

System_CAPS_pubmethodSetName(Object^, String^)

Sets the name of the specified existing object.

NameDescription
System_CAPS_pubeventResolveName

Occurs when GetName cannot locate the specified name in the serialization manager's name table.

System_CAPS_pubeventSerializationComplete

Occurs when serialization is complete.

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.

#using <System.Drawing.dll>
#using <System.dll>
#using <System.Design.dll>

using namespace System;
using namespace System::CodeDom;
using namespace System::ComponentModel;
using namespace System::ComponentModel::Design;
using namespace System::ComponentModel::Design::Serialization;
using namespace System::Drawing;
using namespace System::Windows::Forms;

namespace CodeDomSerializerSample
{
   ref class MyComponent;
   private ref class MyCodeDomSerializer: public CodeDomSerializer
   {
   public:
      Object^ Deserialize( IDesignerSerializationManager^ manager, Object^ codeObject ) new
      {
         // This is how we associate the component with the serializer.
         CodeDomSerializer^ baseClassSerializer = (CodeDomSerializer^)(
            manager->GetSerializer(
               MyComponent::typeid->BaseType, CodeDomSerializer::typeid ));

         /* This is the simplest case, in which the class just calls the base class
            to do the work. */
         return baseClassSerializer->Deserialize( manager, codeObject );
      }

      Object^ Serialize( IDesignerSerializationManager^ manager, Object^ value ) new
      {
         /* Associate the component with the serializer in the same manner as with
            Deserialize */
         CodeDomSerializer^ baseClassSerializer = (CodeDomSerializer^)(
            manager->GetSerializer(
               MyComponent::typeid->BaseType, CodeDomSerializer::typeid ));

         Object^ codeObject = baseClassSerializer->Serialize( manager, value );

         /* Anything could be in the codeObject.  This sample operates on a
            CodeStatementCollection. */
         if ( (CodeStatementCollection^)(codeObject) )
         {
            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 = gcnew CodeCommentStatement( commentText );
            statements->Insert( 0, comment );
         }
         return codeObject;
      }
   };

   [DesignerSerializer(CodeDomSerializerSample::MyCodeDomSerializer::typeid,
      CodeDomSerializer::typeid)]
   public ref class MyComponent: public Component
   {
   private:
      String^ localProperty;

   public:
      MyComponent()
      {
         localProperty = "Component Property Value";
      }

      property String^ LocalProperty 
      {
         String^ get()
         {
            return localProperty;
         }
         void set( String^ value )
         {
            localProperty = value;
         }
      }
   };
}

.NET Framework
Available since 1.1
Return to top
Show: