DesignerSerializationVisibilityAttributeとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > DesignerSerializationVisibilityAttributeの意味・解説 

DesignerSerializationVisibilityAttribute クラス

デザイン時にコンポーネントプロパティシリアル化するときに使用する永続化種類指定します

名前空間: System.ComponentModel
アセンブリ: System (system.dll 内)
構文構文

<AttributeUsageAttribute(AttributeTargets.Method Or AttributeTargets.Property
 Or AttributeTargets.Field Or AttributeTargets.Event)>
 _
Public NotInheritable Class
 DesignerSerializationVisibilityAttribute
    Inherits Attribute
Dim instance As DesignerSerializationVisibilityAttribute
[AttributeUsageAttribute(AttributeTargets.Method|AttributeTargets.Property|AttributeTargets.Field|AttributeTargets.Event)]
 
public sealed class DesignerSerializationVisibilityAttribute
 : Attribute
[AttributeUsageAttribute(AttributeTargets::Method|AttributeTargets::Property|AttributeTargets::Field|AttributeTargets::Event)]
 
public ref class DesignerSerializationVisibilityAttribute
 sealed : public Attribute
/** @attribute AttributeUsageAttribute(AttributeTargets.Method|AttributeTargets.Property|AttributeTargets.Field|AttributeTargets.Event)
 */ 
public final class DesignerSerializationVisibilityAttribute
 extends Attribute
AttributeUsageAttribute(AttributeTargets.Method|AttributeTargets.Property|AttributeTargets.Field|AttributeTargets.Event)
 
public final class DesignerSerializationVisibilityAttribute
 extends Attribute
解説解説

シリアライザでデザイン モード ドキュメント永続化状態を設定する場合に、デザイン時に設定されプロパティの値を永続化するために、コンポーネント初期化メソッドコード追加することがよくあります。他の動作指示する属性設定されていなければ、ほとんどの基本的なに対して既定でこれが行われます

DesignerSerializationVisibilityAttribute使用すると、プロパティの値を Visible として初期化コード永続化するのか、Hidden として初期化コード永続化しないのか、または Content として、そのプロパティ代入するオブジェクトパブリックな、隠ぺいされていないプロパティに対して初期化コード生成する必要があるのかを示すことができます

DesignerSerializationVisibilityAttribute のないメンバは、値が VisibleDesignerSerializationVisibilityAttribute を持つものとして扱われます。Visible としてマークされプロパティの値は、可能であれば、その型のシリアライザでシリアル化されます特定の型やプロパティに対してカスタムシリアル化指定するには、DesignerSerializerAttribute を使用します

詳細については、属性概要属性使用したメタデータ拡張 の各トピック参照してください

使用例使用例

Content設定されDesignerSerializationVisibilityAttribute使用方法次のコード例示します。この例では、デザイン時に構成できる、ユーザー コントロールパブリック プロパティの値を永続化ます。この例を使用するには、最初に次のコードコンパイルして、ユーザー コントロール ライブラリ作成します次に新しWindows アプリケーション プロジェクトで、コンパイルされた .dll ファイルへの参照追加しますVisual Studio使用している場合は、ContentSerializationExampleControl自動的に ツールボックス追加されます。

ツールボックス からコントロールフォームドラッグし、[プロパティ] ウィンドウの一覧に示されている DimensionData オブジェクトプロパティ設定しますフォームコード表示すると、コードが親フォームInitializeComponent メソッド追加されています。このコードは、コントロールプロパティの値を、デザイン モード設定した値に設定します

Imports System
Imports System.Collections
Imports System.ComponentModel
Imports System.ComponentModel.Design
Imports System.Drawing
Imports System.Windows.Forms

Namespace DesignerSerializationVisibilityTest
    _
    ' The code for this user control declares a public property of type
 DimensionData with a DesignerSerializationVisibility 
    ' attribute set to DesignerSerializationVisibility.Content, indicating
 that the properties of the object should be serialized.

    ' The public, not hidden properties of the object that are set at
 design time will be persisted in the initialization code
    ' for the class object. Content persistence will not work for structs
 without a custom TypeConverter.        
    Public Class ContentSerializationExampleControl
        Inherits System.Windows.Forms.UserControl
        Private components As System.ComponentModel.Container
 = Nothing


        <DesignerSerializationVisibility(DesignerSerializationVisibility.Content)>
 _
        Public ReadOnly Property
 Dimensions() As DimensionData
            Get
                Return New DimensionData(Me)
            End Get
        End Property


        Public Sub New()
            InitializeComponent()
        End Sub 'New


        Protected Overloads Sub
 Dispose(ByVal disposing As Boolean)
            If disposing Then
                If Not (components Is
 Nothing) Then
                    components.Dispose()
                End If
            End If
            MyBase.Dispose(disposing)
        End Sub 'Dispose


        Private Sub InitializeComponent()
        End Sub 'InitializeComponent
    End Class 'ContentSerializationExampleControl

    ' This attribute indicates that the public properties of this object
 should be listed in the property grid.
   <TypeConverterAttribute(GetType(System.ComponentModel.ExpandableObjectConverter))>
 _   
    Public Class DimensionData
        Private owner As Control

        ' This class reads and writes the Location and Size properties
 from the Control which it is initialized to.
        Friend Sub New(ByVal
 owner As Control)
            Me.owner = owner
        End Sub 'New


        Public Property Location() As
 Point
            Get
                Return owner.Location
            End Get
            Set(ByVal Value As
 Point)
                owner.Location = Value
            End Set
        End Property


        Public Property FormSize() As
 Size
            Get
                Return owner.Size
            End Get
            Set(ByVal Value As
 Size)
                owner.Size = Value
            End Set
        End Property
    End Class 'DimensionData
End Namespace 'DesignerSerializationVisibilityTest
using System;
using System.Collections;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Drawing;
using System.Windows.Forms;

namespace DesignerSerializationVisibilityTest
{
    // The code for this user control declares a public property of
 type DimensionData with a DesignerSerializationVisibility 
    // attribute set to DesignerSerializationVisibility.Content, indicating
 that the properties of the object should be serialized.

    // The public, not hidden properties of the object that are set
 at design time will be persisted in the initialization code
    // for the class object. Content persistence will not work for structs
 without a custom TypeConverter.        

    public class ContentSerializationExampleControl
 : System.Windows.Forms.UserControl
    {
    private System.ComponentModel.Container components = null;
                
    
    [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
    public DimensionData Dimensions
    {
        get 
        {
        return new DimensionData(this);
        }        
    }

    public ContentSerializationExampleControl()
    {
            InitializeComponent();        
    }
        
    protected override void Dispose( bool
 disposing )
    {
        if( disposing )
        {
        if( components != null )
            components.Dispose();
        }
        base.Dispose( disposing );
    }

    private void InitializeComponent()
    {
        components = new System.ComponentModel.Container();
    }
    }

    [TypeConverterAttribute(typeof(System.ComponentModel.ExpandableObjectConverter))]
    // This attribute indicates that the public properties of this object
 should be listed in the property grid.
    public class DimensionData
    {        
    private Control owner;

    // This class reads and writes the Location and Size properties
 from the Control which it is initialized to.
    internal DimensionData(Control owner)
    {
            this.owner = owner;            
    }

    public Point Location
    {
        get
        {
        return owner.Location;
        }
        set
        {
        owner.Location = value;
        }
    }

    public Size FormSize
    {
        get
            {
        return owner.Size;
        }
        set
        {
        owner.Size = value;
        }
    }
    }
}
#using <System.Windows.Forms.dll>
#using <System.Drawing.dll>
#using <System.dll>

using namespace System;
using namespace System::Collections;
using namespace System::ComponentModel;
using namespace System::ComponentModel::Design;
using namespace System::Drawing;
using namespace System::Windows::Forms;

// This attribute indicates that the public properties of this object
 should be listed in the property grid.

[TypeConverterAttribute(System::ComponentModel::ExpandableObjectConverter::typeid)]
public ref class DimensionData
{
private:
   Control^ owner;

internal:

   // This class reads and writes the Location and Size properties from
 the Control which it is initialized to.
   DimensionData( Control^ owner )
   {
      this->owner = owner;
   }

public:

   property Point Location 
   {
      Point get()
      {
         return owner->Location;
      }

      void set( Point value )
      {
         owner->Location = value;
      }

   }

   property Size FormSize 
   {
      Size get()
      {
         return owner->Size;
      }

      void set( Size value )
      {
         owner->Size = value;
      }
   }
};

// The code for this user control declares a public property of type
 DimensionData with a DesignerSerializationVisibility 
// attribute set to DesignerSerializationVisibility.Content, indicating
 that the properties of the object should be serialized.
// The public, not hidden properties of the object that are set at design
 time will be persisted in the initialization code
// for the class object. Content persistence will not work for structs
 without a custom TypeConverter.  
public ref class ContentSerializationExampleControl:
 public System::Windows::Forms::UserControl
{
private:
   System::ComponentModel::Container^ components;

public:

   property DimensionData^ Dimensions 
   {
      [DesignerSerializationVisibility(DesignerSerializationVisibility::Content)]
      DimensionData^ get()
      {
         return gcnew DimensionData( this );
      }
   }
   ContentSerializationExampleControl()
   {
      InitializeComponent();
   }

public:
   ~ContentSerializationExampleControl()
   {
      if ( components != nullptr )
      {
         delete components;
      }
   }

private:
   void InitializeComponent()
   {
      components = gcnew System::ComponentModel::Container;
   }
};
package DesignerSerializationVisibilityTest;

import System.*;
import System.Collections.*;
import System.ComponentModel.*;
import System.ComponentModel.Design.*;
import System.Drawing.*;
import System.Windows.Forms.*;

// The code for this user control declares a public property of type
 
// DimensionData with a DesignerSerializationVisibility attribute set
 
// to DesignerSerializationVisibility.Content, indicating that the properties
 
// of the object should be serialized.
// The public, not hidden properties of the object that are set at design
 
// time will be persisted in the initialization code for the class object.
 
// Content persistence will not work for structs without a custom 
// TypeConverter.        

public class ContentSerializationExampleControl
   extends System.Windows.Forms.UserControl
{
    private System.ComponentModel.Container components = null;

    /** @attribute DesignerSerializationVisibility(
         DesignerSerializationVisibility.Content)
     */
    /** @property 
     */
    public DimensionData get_Dimensions()
    {
        return new DimensionData(this);
    } //get_Dimensions

    public ContentSerializationExampleControl()
    {
        InitializeComponent();
    } //ContentSerializationExampleControl

    protected void Dispose(boolean disposing)
    {
        if (disposing) {
            if (components != null) {
                components.Dispose();
            }
        }
        super.Dispose(disposing);
    } //Dispose

    private void InitializeComponent()
    {
        components = new System.ComponentModel.Container();
    } //InitializeComponent
} //ContentSerializationExampleControl

/** @attribute TypeConverterAttribute(System.ComponentModel.
     ExpandableObjectConverter.class)
 */
public class DimensionData
{
    // This attribute indicates that the public properties of this 
    // object should be listed in the property grid.
    private Control owner;

    // This class reads and writes the Location and Size properties
 
    // from the Control which it is initialized to.
    DimensionData(Control owner)
    {
        this.owner = owner;
    } //DimensionData

    /** @property 
     */
    public Point get_Location()
    {
        return owner.get_Location();
    } //get_Location

    /** @property 
     */
    public void set_Location(Point value)
    {
        owner.set_Location(value);
    } //set_Location

    /** @property 
     */
    public Size get_FormSize()
    {
        return owner.get_Size();
    } //get_FormSize

    /** @property 
     */
    public void set_FormSize(Size value)
    {
        owner.set_Size(value);
    } //set_FormSize
} //DimensionData
継承階層継承階層
System.Object
   System.Attribute
    System.ComponentModel.DesignerSerializationVisibilityAttribute
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバ場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
DesignerSerializationVisibilityAttribute メンバ
System.ComponentModel 名前空間
Attribute
PropertyDescriptor
AttributeCollection クラス
PropertyDescriptorCollection
その他の技術情報
方法 : 標準の型のコレクションを DesignerSerializationVisibilityAttribute でシリアル化する

DesignerSerializationVisibilityAttribute コンストラクタ

DesignerSerializationVisibility 値を指定して、DesignerSerializationVisibilityAttribute クラス新しインスタンス初期化します。

名前空間: System.ComponentModel
アセンブリ: System (system.dll 内)
構文構文

Public Sub New ( _
    visibility As DesignerSerializationVisibility _
)
Dim visibility As DesignerSerializationVisibility

Dim instance As New DesignerSerializationVisibilityAttribute(visibility)
public DesignerSerializationVisibilityAttribute (
    DesignerSerializationVisibility visibility
)
public:
DesignerSerializationVisibilityAttribute (
    DesignerSerializationVisibility visibility
)
public DesignerSerializationVisibilityAttribute (
    DesignerSerializationVisibility visibility
)
public function DesignerSerializationVisibilityAttribute
 (
    visibility : DesignerSerializationVisibility
)

パラメータ

visibility

DesignerSerializationVisibility 値の 1 つ

使用例使用例

デザイナによるコンポーネントプロパティ保存方法次のコード例示します。このコードは、新しDesignerSerializationVisibilityAttribute作成し、その値を DesignerSerializationVisibilityAttribute.Content に設定します

<DesignerSerializationVisibility(DesignerSerializationVisibility.Content)>
 _
Public Property _
    MyProperty() As Integer
    
    Get
        ' Insert code here.
        Return 0
    End Get
    Set
        ' Insert code here.
    End Set 
End Property
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
 public int MyProperty {
    get {
       // Insert code here.
       return(0);
    }
    set {
       // Insert code here.
    }
 }
public:
   [DesignerSerializationVisibility(DesignerSerializationVisibility::Content)]
   property int MyProperty 
   {
      int get()
      {
         // Insert code here.
         return (0);
      }
      void set( int value
 )
      {
         // Insert code here.
      }
   }
/** @attribute DesignerSerializationVisibility(
    DesignerSerializationVisibility.Content)
 */
/** @property 
 */
public int get_MyProperty()
{
    // Insert code here.
    return 0;
} //get_MyProperty

/** @property 
 */
public void set_MyProperty(int
 value)
{
    // Insert code here.
} //set_MyProperty
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
DesignerSerializationVisibilityAttribute クラス
DesignerSerializationVisibilityAttribute メンバ
System.ComponentModel 名前空間
DesignerSerializationVisibilityAttribute クラス

DesignerSerializationVisibilityAttribute フィールド


パブリック フィールドパブリック フィールド

参照参照

関連項目

DesignerSerializationVisibilityAttribute クラス
System.ComponentModel 名前空間
Attribute
PropertyDescriptor
AttributeCollection クラス
PropertyDescriptorCollection

その他の技術情報

方法 : 標準の型のコレクションを DesignerSerializationVisibilityAttribute でシリアル化する

DesignerSerializationVisibilityAttribute プロパティ


パブリック プロパティパブリック プロパティ

参照参照

関連項目

DesignerSerializationVisibilityAttribute クラス
System.ComponentModel 名前空間
Attribute
PropertyDescriptor
AttributeCollection クラス
PropertyDescriptorCollection

その他の技術情報

方法 : 標準の型のコレクションを DesignerSerializationVisibilityAttribute でシリアル化する

DesignerSerializationVisibilityAttribute メソッド


パブリック メソッドパブリック メソッド

( プロテクト メソッド参照)
  名前 説明
パブリック メソッド Equals オーバーロードされますオーバーライドされます。 このインスタンス指定したオブジェクト等しかどうか示します
パブリック メソッド GetCustomAttribute  オーバーロードされますアセンブリモジュール、型のメンバ、またはメソッド パラメータ適用され指定した型のカスタム属性取得します。 ( Attribute から継承されます。)
パブリック メソッド GetCustomAttributes  オーバーロードされますアセンブリモジュール、型のメンバ、またはメソッド パラメータ適用されカスタム属性配列取得します。 ( Attribute から継承されます。)
パブリック メソッド GetHashCode オーバーライドされます。 このオブジェクトハッシュ コード返します
パブリック メソッド GetType  現在のインスタンスType取得します。 ( Object から継承されます。)
パブリック メソッド IsDefaultAttribute オーバーライドされます属性現在の値が既定値かどうかを示す値を取得します
パブリック メソッド IsDefined  オーバーロードされます指定した型のカスタム属性が、アセンブリモジュール、型のメンバ、またはメソッド パラメータ適用されているかどうか判断します。 ( Attribute から継承されます。)
パブリック メソッド Match  派生クラス内でオーバーライドされたときに、指定したオブジェクトとこのインスタンス等しかどうかを示す値を返します。 ( Attribute から継承されます。)
パブリック メソッド ReferenceEquals  指定した複数Object インスタンス同一かどうか判断します。 ( Object から継承されます。)
パブリック メソッド ToString  現在の Object を表す String返します。 ( Object から継承されます。)
プロテクト メソッドプロテクト メソッド
参照参照

関連項目

DesignerSerializationVisibilityAttribute クラス
System.ComponentModel 名前空間
Attribute
PropertyDescriptor
AttributeCollection クラス
PropertyDescriptorCollection

その他の技術情報

方法 : 標準の型のコレクションを DesignerSerializationVisibilityAttribute でシリアル化する

DesignerSerializationVisibilityAttribute メンバ

デザイン時にコンポーネントプロパティシリアル化するときに使用する永続化種類指定します

DesignerSerializationVisibilityAttribute データ型公開されるメンバを以下の表に示します


パブリック コンストラクタパブリック コンストラクタ
  名前 説明
パブリック メソッド DesignerSerializationVisibilityAttribute DesignerSerializationVisibility 値を指定して、DesignerSerializationVisibilityAttribute クラス新しインスタンス初期化します。
パブリック フィールドパブリック フィールド
パブリック プロパティパブリック プロパティ
パブリック メソッドパブリック メソッド
( プロテクト メソッド参照)
  名前 説明
パブリック メソッド Equals オーバーロードされますオーバーライドされます。 このインスタンス指定したオブジェクト等しかどうか示します
パブリック メソッド GetCustomAttribute  オーバーロードされますアセンブリモジュール、型のメンバ、またはメソッド パラメータ適用され指定した型のカスタム属性取得します。 (Attribute から継承されます。)
パブリック メソッド GetCustomAttributes  オーバーロードされますアセンブリモジュール、型のメンバ、またはメソッド パラメータ適用されカスタム属性配列取得します。 (Attribute から継承されます。)
パブリック メソッド GetHashCode オーバーライドされます。 このオブジェクトハッシュ コード返します
パブリック メソッド GetType  現在のインスタンスType取得します。 (Object から継承されます。)
パブリック メソッド IsDefaultAttribute オーバーライドされます属性現在の値が既定値かどうかを示す値を取得します
パブリック メソッド IsDefined  オーバーロードされます指定した型のカスタム属性が、アセンブリモジュール、型のメンバ、またはメソッド パラメータ適用されているかどうか判断します。 (Attribute から継承されます。)
パブリック メソッド Match  派生クラス内でオーバーライドされたときに、指定したオブジェクトとこのインスタンス等しかどうかを示す値を返します。 (Attribute から継承されます。)
パブリック メソッド ReferenceEquals  指定した複数Object インスタンス同一かどうか判断します。 (Object から継承されます。)
パブリック メソッド ToString  現在の Object を表す String返します。 (Object から継承されます。)
プロテクト メソッドプロテクト メソッド
参照参照

関連項目

DesignerSerializationVisibilityAttribute クラス
System.ComponentModel 名前空間
Attribute
PropertyDescriptor
AttributeCollection クラス
PropertyDescriptorCollection

その他の技術情報

方法 : 標準の型のコレクションを DesignerSerializationVisibilityAttribute でシリアル化する


このページでは「.NET Framework クラス ライブラリ リファレンス」からDesignerSerializationVisibilityAttributeを検索した結果を表示しています。
Weblioに収録されているすべての辞書からDesignerSerializationVisibilityAttributeを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からDesignerSerializationVisibilityAttribute を検索

英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「DesignerSerializationVisibilityAttribute」の関連用語

DesignerSerializationVisibilityAttributeのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



DesignerSerializationVisibilityAttributeのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS