IDesignerSerializationManager イベント

名前 | 説明 | |
---|---|---|
![]() | ResolveName | GetName が、指定した名前をシリアル化マネージャの名前テーブル内で見つけられなかった場合に発生します。 |
![]() | SerializationComplete | シリアル化が完了したときに発生します。 |

IDesignerSerializationManager インターフェイス
アセンブリ: System (system.dll 内)


デザイナは、IDesignerSerializationManager を利用して、デザイン時のシリアル化処理の管理に役立つサービスにアクセスできます。たとえば、デザイナ シリアル化マネージャを実装しているクラスは、このインターフェイスを使用して、オブジェクトの作成、型の検索、オブジェクトの識別、および特定の型のシリアル化のカスタマイズを実行できます。

IDesignerSerializationManager を使用して、Code DOM ステートメントをシリアル化および逆シリアル化する方法を次の例に示します。
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
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; } } } }
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 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
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


IDesignerSerializationManager プロパティ

名前 | 説明 | |
---|---|---|
![]() | Context | シリアライザ間の通信に役立つスタック ベースのユーザー定義ストレージ エリアを取得します。 |
![]() | Properties | 有効なシリアライザを使用してシリアル化できるカスタム プロパティを示します。 |

IDesignerSerializationManager メソッド

名前 | 説明 | |
---|---|---|
![]() | AddSerializationProvider | 指定したシリアル化プロバイダをシリアル化マネージャに追加します。 |
![]() | CreateInstance | 指定した型のインスタンスを作成し、作成したインスタンスを名前付きインスタンスのコレクションに追加します。 |
![]() | GetInstance | 指定した名前で作成されたオブジェクトのインスタンスを取得します。そのようなオブジェクトが存在しない場合は null 参照 (Visual Basic では Nothing) を取得します。 |
![]() | GetName | 指定したオブジェクトの名前を取得します。オブジェクトに名前がない場合は null 参照 (Visual Basic では Nothing) を取得します。 |
![]() | GetSerializer | 指定したオブジェクト型に対応する、要求された型のシリアライザを取得します。 |
![]() | GetType | 指定した名前の型を取得します。 |
![]() | RemoveSerializationProvider | カスタム シリアル化プロバイダをシリアル化マネージャから削除します。 |
![]() | ReportError | シリアル化時のエラーを報告します。 |
![]() | SetName | 指定した既存のオブジェクトの名前を設定します。 |

IDesignerSerializationManager メンバ
デザイン時のシリアル化を管理するためのインターフェイスを提供します。
IDesignerSerializationManager データ型で公開されるメンバを以下の表に示します。

名前 | 説明 | |
---|---|---|
![]() | Context | シリアライザ間の通信に役立つスタック ベースのユーザー定義ストレージ エリアを取得します。 |
![]() | Properties | 有効なシリアライザを使用してシリアル化できるカスタム プロパティを示します。 |

名前 | 説明 | |
---|---|---|
![]() | AddSerializationProvider | 指定したシリアル化プロバイダをシリアル化マネージャに追加します。 |
![]() | CreateInstance | 指定した型のインスタンスを作成し、作成したインスタンスを名前付きインスタンスのコレクションに追加します。 |
![]() | GetInstance | 指定した名前で作成されたオブジェクトのインスタンスを取得します。そのようなオブジェクトが存在しない場合は null 参照 (Visual Basic では Nothing) を取得します。 |
![]() | GetName | 指定したオブジェクトの名前を取得します。オブジェクトに名前がない場合は null 参照 (Visual Basic では Nothing) を取得します。 |
![]() | GetSerializer | 指定したオブジェクト型に対応する、要求された型のシリアライザを取得します。 |
![]() | GetType | 指定した名前の型を取得します。 |
![]() | RemoveSerializationProvider | カスタム シリアル化プロバイダをシリアル化マネージャから削除します。 |
![]() | ReportError | シリアル化時のエラーを報告します。 |
![]() | SetName | 指定した既存のオブジェクトの名前を設定します。 |

名前 | 説明 | |
---|---|---|
![]() | ResolveName | GetName が、指定した名前をシリアル化マネージャの名前テーブル内で見つけられなかった場合に発生します。 |
![]() | SerializationComplete | シリアル化が完了したときに発生します。 |

- IDesignerSerializationManagerのページへのリンク