IDesignerSerializationManager 인터페이스

정의

디자인 타임 serialization을 관리할 수 있는 인터페이스를 제공합니다.

public interface class IDesignerSerializationManager : IServiceProvider
public interface IDesignerSerializationManager : IServiceProvider
type IDesignerSerializationManager = interface
    interface IServiceProvider
Public Interface IDesignerSerializationManager
Implements IServiceProvider
파생
구현

예제

다음 예제에서는 를 사용하여 IDesignerSerializationManager Code DOM 문을 직렬화하고 역직렬화하는 방법을 보여 줍니다.

#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;
         }
      }
   };
}
using System;
using System.CodeDom;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.ComponentModel.Design.Serialization;
using System.Drawing;
using System.Windows.Forms;
 
namespace CodeDomSerializerSample
{
    internal class MyCodeDomSerializer : CodeDomSerializer {
        public override object Deserialize(IDesignerSerializationManager manager, object codeObject) {
            // This is how we associate the component with the serializer.
                CodeDomSerializer baseClassSerializer = (CodeDomSerializer)manager.
                GetSerializer(typeof(MyComponent).BaseType, typeof(CodeDomSerializer));

            /* This is the simplest case, in which the class just calls the base class
                to do the work. */
            return baseClassSerializer.Deserialize(manager, codeObject);
        }
 
        public override object Serialize(IDesignerSerializationManager manager, object value) {
            /* Associate the component with the serializer in the same manner as with
                Deserialize */
            CodeDomSerializer baseClassSerializer = (CodeDomSerializer)manager.
                GetSerializer(typeof(MyComponent).BaseType, typeof(CodeDomSerializer));
 
            object codeObject = baseClassSerializer.Serialize(manager, value);
 
            /* Anything could be in the codeObject.  This sample operates on a
                CodeStatementCollection. */
            if (codeObject is 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;
        }
    }
 
    [DesignerSerializer(typeof(MyCodeDomSerializer), typeof(CodeDomSerializer))]
    public class MyComponent : Component {
        private string localProperty = "Component Property Value";
        public string LocalProperty {
            get {
                return localProperty;
            }
            set {
                localProperty = value;
            }
        }
    }
}
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

   <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

End Namespace

설명

디자이너는 를 활용하여 IDesignerSerializationManager 디자인 타임 직렬화 프로세스를 관리하는 데 유용한 서비스에 액세스할 수 있습니다. 예를 들어 디자이너 serialization 관리자를 구현하는 클래스는 이 인터페이스를 사용하여 개체를 만들고, 형식을 조회하고, 개체를 식별하고, 특정 형식의 serialization을 사용자 지정할 수 있습니다.

속성

Context

serializer 간의 통신에 유용한 스택 기반의 사용자 정의 스토리지 영역을 가져옵니다.

Properties

사용 가능한 serializer를 통해 serialize할 수 있는 사용자 지정 속성을 나타냅니다.

메서드

AddSerializationProvider(IDesignerSerializationProvider)

지정된 serialization 공급자를 serialization 관리자에 추가합니다.

CreateInstance(Type, ICollection, String, Boolean)

지정된 형식의 인스턴스를 만들어 명명된 인스턴스의 컬렉션에 추가합니다.

GetInstance(String)

지정된 이름으로 만들어진 개체 인스턴스를 가져오거나, 해당 개체가 없으면 null입니다.

GetName(Object)

지정된 개체의 이름을 가져오거나, 개체에 이름이 없으면 null입니다.

GetSerializer(Type, Type)

지정된 개체 형식에 대한 요청된 형식의 serializer를 가져옵니다.

GetService(Type)

지정된 형식의 서비스 개체를 가져옵니다.

(다음에서 상속됨 IServiceProvider)
GetType(String)

지정된 이름의 형식을 가져옵니다.

RemoveSerializationProvider(IDesignerSerializationProvider)

사용자 지정 serialization 공급자를 serialization 관리자에서 제거합니다.

ReportError(Object)

serialization의 오류를 보고합니다.

SetName(Object, String)

지정된 기존 개체의 이름을 설정합니다.

이벤트

ResolveName

GetName(Object)이 지정된 이름을 serialization 관리자의 이름 테이블에서 찾을 수 없을 때 발생합니다.

SerializationComplete

serialization이 완료되었을 때 발생합니다.

적용 대상

추가 정보