DesignerSerializationVisibilityAttribute DesignerSerializationVisibilityAttribute DesignerSerializationVisibilityAttribute DesignerSerializationVisibilityAttribute Class

정의

디자인 타임에 구성 요소에서 속성을 serialize할 때 사용할 지속성 형식을 지정합니다.Specifies the type of persistence to use when serializing a property on a component at design time.

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

예제

다음 코드 예제에서는 한 DesignerSerializationVisibilityAttributeContent합니다.The following code example demonstrates the use of a DesignerSerializationVisibilityAttribute set to Content. 디자인 타임에 구성 될 수 있는 사용자 컨트롤의 공용 속성의 값을 유지 합니다.It persists the values of a public property of a user control, which can be configured at design time. 예제를 사용 하려면 먼저 다음 코드를 사용자 정의 컨트롤 라이브러리를 컴파일하십시오.To use the example, first compile the following code into a user control library. 다음으로 새 Windows 응용 프로그램 프로젝트의 컴파일된.dll 파일에 대 한 참조를 추가 합니다.Next, add a reference to the compiled .dll file in a new Windows Application project. Visual Studio를 사용 하는 경우는 ContentSerializationExampleControl 자동으로 추가 되는 도구 상자합니다.If you are using Visual Studio, the ContentSerializationExampleControl is automatically added to the Toolbox.

컨트롤을 끌어를 도구 상자 형식으로의 속성을 설정 하 고를 DimensionData 속성 창에 나열 된 개체입니다.Drag the control from the Toolbox to a form, and set the properties of the DimensionData object listed in the Properties window. 폼에 대 한 코드를 볼 때 코드를 추가한는 InitializeComponent 부모 폼의 메서드.When you view the code for the form, code will have been added to the InitializeComponent method of the parent form. 이 코드를 디자인 모드로 설정한 경우에 해당 컨트롤의 속성 값을 설정 합니다.This code sets the values of the control's properties to those which you have set in design mode.

#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
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 (components IsNot 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

설명

디자인 모드 문서의 지속적인 상태를 유지 하는 serializer를 디자인 타임에 설정 된 속성의 값을 유지 하는 구성 요소 초기화 메서드를 종종 코드를 추가 합니다.When a serializer persists the persistable state of a design mode document, it often adds code to the initialization method of components to persist values of properties that have been set at design time. 동작은 다른 동작에 설정 된 특성이 없는 경우 가장 기본적인 형식에 대해 기본적으로 발생 합니다.This happens by default for most basic types, if no attribute has been set to direct other behavior.

사용 하 여는 DesignerSerializationVisibilityAttribute, 속성의 값이 있는지 여부를 지정할 수 있습니다 Visible, 초기화 코드에서 유지 Hidden, 및 초기화 코드에서 유지할 수 없는 또는 이루어져 Content, 있는 속성에 할당 된 개체의 숨겨지지 않은 각 public 속성에 대해 생성 된 초기화 코드입니다.With the DesignerSerializationVisibilityAttribute, you can indicate whether the value for a property is Visible, and should be persisted in initialization code, Hidden, and should not be persisted in initialization code, or consists of Content, which should have initialization code generated for each public, not hidden property of the object assigned to the property.

없는 멤버를 DesignerSerializationVisibilityAttribute 것으로 간주 됩니다는 DesignerSerializationVisibilityAttribute 의 값을 사용 하 여 Visible입니다.Members that do not have a DesignerSerializationVisibilityAttribute will be treated as though they have a DesignerSerializationVisibilityAttribute with a value of Visible. 속성의 값으로 표시 Visible serialize 될, 가능한 경우 형식에 대 한 직렬 변환기를 통해.The values of a property marked as Visible will be serialized, if possible, by a serializer for the type. 특정 형식 또는 속성에 대 한 사용자 지정 serialization을 지정 하려면 사용 된 DesignerSerializerAttribute합니다.To specify custom serialization for a particular type or property, use the DesignerSerializerAttribute.

자세한 내용은 특성을 참조하세요.For more information, see Attributes.

생성자

DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility) DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility) DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility) DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility)

지정된 DesignerSerializationVisibilityAttribute 값을 사용하여 DesignerSerializationVisibility 클래스의 새 인스턴스를 초기화합니다.Initializes a new instance of the DesignerSerializationVisibilityAttribute class using the specified DesignerSerializationVisibility value.

필드

Content Content Content Content

serializer에서 해당 속성 자체가 아니라 속성의 내용을 serialize하도록 지정합니다.Specifies that a serializer should serialize the contents of the property, rather than the property itself. 이 필드는 읽기 전용입니다.This field is read-only.

Default Default Default Default

기본값인 Visible을 지정합니다. 즉, 비주얼 디자이너가 기본 규칙을 사용하여 속성 값을 생성합니다.Specifies the default value, which is Visible, that is, a visual designer uses default rules to generate the value of a property. static 필드는 읽기 전용입니다.This static field is read-only.

Hidden Hidden Hidden Hidden

serializer에서 해당 속성의 값을 serialize하지 않도록 지정합니다.Specifies that a serializer should not serialize the value of the property. static 필드는 읽기 전용입니다.This static field is read-only.

Visible Visible Visible Visible

serializer에서 해당 속성의 값을 serialize하지 못하도록 지정합니다.Specifies that a serializer should be allowed to serialize the value of the property. static 필드는 읽기 전용입니다.This static field is read-only.

속성

TypeId TypeId TypeId TypeId

파생 클래스에서 구현된 경우 이 Attribute에 대한 고유 식별자를 가져옵니다.When implemented in a derived class, gets a unique identifier for this Attribute.

(Inherited from Attribute)
Visibility Visibility Visibility Visibility

serializer에서 속성 값의 유지 여부 및 유지 방식을 결정할 때 사용할 기본 serialization 모드를 나타내는 값을 가져옵니다.Gets a value indicating the basic serialization mode a serializer should use when determining whether and how to persist the value of a property.

메서드

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

이 인스턴스와 지정된 개체가 같은지 여부를 나타냅니다.Indicates whether this instance and a specified object are equal.

GetHashCode() GetHashCode() GetHashCode() GetHashCode()

해당 개체의 해시 코드를 반환합니다.Returns the hash code for this object.

GetType() GetType() GetType() GetType()

현재 인스턴스의 Type을 가져옵니다.Gets the Type of the current instance.

(Inherited from Object)
IsDefaultAttribute() IsDefaultAttribute() IsDefaultAttribute() IsDefaultAttribute()

현재 특성 값이 해당 특성의 기본값인지 여부를 나타내는 값을 가져옵니다.Gets a value indicating whether the current value of the attribute is the default value for the attribute.

Match(Object) Match(Object) Match(Object) Match(Object)

파생 클래스에서 재정의된 경우 이 인스턴스가 지정된 개체와 같은지 여부를 나타내는 값을 반환합니다.When overridden in a derived class, returns a value that indicates whether this instance equals a specified object.

(Inherited from Attribute)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

현재 Object의 단순 복사본을 만듭니다.Creates a shallow copy of the current Object.

(Inherited from Object)
ToString() ToString() ToString() ToString()

현재 개체를 나타내는 문자열을 반환합니다.Returns a string that represents the current object.

(Inherited from Object)

명시적 인터페이스 구현

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

이름 집합을 해당하는 디스패치 식별자 집합에 매핑합니다.Maps a set of names to a corresponding set of dispatch identifiers.

(Inherited from Attribute)
_Attribute.GetTypeInfo(UInt32, UInt32, IntPtr) _Attribute.GetTypeInfo(UInt32, UInt32, IntPtr) _Attribute.GetTypeInfo(UInt32, UInt32, IntPtr) _Attribute.GetTypeInfo(UInt32, UInt32, IntPtr)

인터페이스의 형식 정보를 가져오는 데 사용할 수 있는 개체의 형식 정보를 검색합니다.Retrieves the type information for an object, which can be used to get the type information for an interface.

(Inherited from Attribute)
_Attribute.GetTypeInfoCount(UInt32) _Attribute.GetTypeInfoCount(UInt32) _Attribute.GetTypeInfoCount(UInt32) _Attribute.GetTypeInfoCount(UInt32)

개체에서 제공하는 형식 정보 인터페이스의 수를 검색합니다(0 또는 1).Retrieves the number of type information interfaces that an object provides (either 0 or 1).

(Inherited from Attribute)
_Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr) _Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr) _Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr) _Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

개체에서 노출하는 메서드와 속성에 대한 액세스를 제공합니다.Provides access to properties and methods exposed by an object.

(Inherited from Attribute)

적용 대상

추가 정보