DesignerSerializationVisibilityAttribute 클래스

정의

디자인 타임에 구성 요소에서 속성을 serialize할 때 사용할 지속성 형식을 지정합니다.

public ref class DesignerSerializationVisibilityAttribute sealed : Attribute
[System.AttributeUsage(System.AttributeTargets.Event | System.AttributeTargets.Field | System.AttributeTargets.Method | System.AttributeTargets.Property)]
public sealed class DesignerSerializationVisibilityAttribute : Attribute
public sealed class DesignerSerializationVisibilityAttribute : Attribute
[System.AttributeUsage(System.AttributeTargets.Method | System.AttributeTargets.Property)]
public sealed class DesignerSerializationVisibilityAttribute : Attribute
[<System.AttributeUsage(System.AttributeTargets.Event | System.AttributeTargets.Field | System.AttributeTargets.Method | System.AttributeTargets.Property)>]
type DesignerSerializationVisibilityAttribute = class
    inherit Attribute
type DesignerSerializationVisibilityAttribute = class
    inherit Attribute
[<System.AttributeUsage(System.AttributeTargets.Method | System.AttributeTargets.Property)>]
type DesignerSerializationVisibilityAttribute = class
    inherit Attribute
Public NotInheritable Class DesignerSerializationVisibilityAttribute
Inherits Attribute
상속
DesignerSerializationVisibilityAttribute
특성

예제

다음 코드 예제에서는 의 집합을 DesignerSerializationVisibilityAttribute 사용하는 방법을 보여 줍니다 Content. 디자인 타임에 구성할 수 있는 사용자 정의 컨트롤의 public 속성 값을 유지합니다. 이 예제를 사용하려면 먼저 다음 코드를 사용자 제어 라이브러리로 컴파일합니다. 다음으로 새 Windows 애플리케이션 프로젝트의 컴파일된.dll 파일에 대 한 참조를 추가 합니다. Visual Studio ContentSerializationExampleControl 를 사용하는 경우 는 도구 상자에 자동으로 추가됩니다.

도구 상자에서 폼으로 컨트롤을 끌어서 속성 창 나열된 개체의 DimensionData 속성을 설정합니다. 폼의 코드를 보면 부모 폼의 메서드에 코드가 InitializeComponent 추가됩니다. 이 코드는 컨트롤의 속성 값을 디자인 모드에서 설정한 값으로 설정합니다.

#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;
   }
};
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;
        }
    }
    }
}
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


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


        Private Sub InitializeComponent()
        End Sub
    End Class

    ' 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


        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
End Namespace 'DesignerSerializationVisibilityTest

설명

직렬 변환기가 디자인 모드 문서의 지속 가능한 상태를 유지하는 경우 디자인 타임에 설정된 속성의 값을 유지하기 위해 구성 요소의 초기화 메서드에 코드를 추가하는 경우가 많습니다. 이는 다른 동작을 지시하도록 설정된 특성이 없는 경우 대부분의 기본 형식에 대해 기본적으로 발생합니다.

DesignerSerializationVisibilityAttribute사용하면 속성 값이 Visible이고 초기화 코드에서 유지되어야 하는지, Hidden초기화 코드에서 유지되어서는 안 되는지 또는 속성에 할당된 개체의 Content숨겨진 속성이 아닌 각 공용에 대해 초기화 코드가 생성되어야 하는 로 구성되어야 하는지 여부를 나타낼 수 있습니다.

가 없는 멤버는 값Visible이 인 DesignerSerializationVisibilityAttribute 가 있는 것처럼 DesignerSerializationVisibilityAttribute 처리됩니다. 로 Visible 표시된 속성의 값은 가능한 경우 형식에 대한 serializer에 의해 serialize됩니다. 특정 형식 또는 속성에 대한 사용자 지정 serialization을 지정하려면 를 DesignerSerializerAttribute사용합니다.

자세한 내용은 특성을 참조하세요.

생성자

DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility)

지정된 DesignerSerializationVisibilityAttribute 값을 사용하여 DesignerSerializationVisibility 클래스의 새 인스턴스를 초기화합니다.

필드

Content

serializer에서 해당 속성 자체가 아니라 속성의 내용을 serialize하도록 지정합니다. 이 필드는 읽기 전용입니다.

Default

기본값인 Visible을 지정합니다. 즉, 비주얼 디자이너가 기본 규칙을 사용하여 속성 값을 생성합니다. 이 static 필드는 읽기 전용입니다.

Hidden

serializer에서 해당 속성의 값을 serialize하지 않도록 지정합니다. 이 static 필드는 읽기 전용입니다.

Visible

serializer에서 해당 속성의 값을 serialize하지 못하도록 지정합니다. 이 static 필드는 읽기 전용입니다.

속성

TypeId

파생 클래스에서 구현된 경우 이 Attribute에 대한 고유 식별자를 가져옵니다.

(다음에서 상속됨 Attribute)
Visibility

serializer에서 속성 값의 유지 여부 및 유지 방식을 결정할 때 사용할 기본 serialization 모드를 나타내는 값을 가져옵니다.

메서드

Equals(Object)

이 인스턴스와 지정된 개체가 같은지 여부를 나타냅니다.

GetHashCode()

이 개체의 해시 코드를 반환합니다.

GetType()

현재 인스턴스의 Type을 가져옵니다.

(다음에서 상속됨 Object)
IsDefaultAttribute()

현재 특성 값이 해당 특성의 기본값인지 여부를 나타내는 값을 가져옵니다.

IsDefaultAttribute()

파생 클래스에서 재정의된 경우 이 인스턴스 값이 파생 클래스에 대한 기본값인지 여부를 표시합니다.

(다음에서 상속됨 Attribute)
Match(Object)

파생 클래스에서 재정의된 경우 이 인스턴스가 지정된 개체와 같은지 여부를 나타내는 값을 반환합니다.

(다음에서 상속됨 Attribute)
MemberwiseClone()

현재 Object의 단순 복사본을 만듭니다.

(다음에서 상속됨 Object)
ToString()

현재 개체를 나타내는 문자열을 반환합니다.

(다음에서 상속됨 Object)

명시적 인터페이스 구현

_Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr)

이름 집합을 해당하는 디스패치 식별자 집합에 매핑합니다.

(다음에서 상속됨 Attribute)
_Attribute.GetTypeInfo(UInt32, UInt32, IntPtr)

인터페이스의 형식 정보를 가져오는 데 사용할 수 있는 개체의 형식 정보를 검색합니다.

(다음에서 상속됨 Attribute)
_Attribute.GetTypeInfoCount(UInt32)

개체에서 제공하는 형식 정보 인터페이스의 수를 검색합니다(0 또는 1).

(다음에서 상속됨 Attribute)
_Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

개체에서 노출하는 메서드와 속성에 대한 액세스를 제공합니다.

(다음에서 상속됨 Attribute)

적용 대상

추가 정보