DesignerSerializationVisibilityAttribute Sınıf

Tanım

Tasarım zamanında bir bileşende bir özelliği seri hale getirdiğinizde kullanılacak kalıcılık türünü belirtir.

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
Devralma
DesignerSerializationVisibilityAttribute
Öznitelikler

Örnekler

Aşağıdaki kod örneğinde olarak ayarlanmış bir DesignerSerializationVisibilityAttribute kümenin Contentkullanımı gösterilmektedir. Bir kullanıcı denetiminin ortak özelliğinin değerlerini kalıcı hale alır ve bu değer tasarım zamanında yapılandırılabilir. Örneği kullanmak için önce aşağıdaki kodu bir kullanıcı denetim kitaplığına derleyin. Ardından, yeni bir Windows Uygulaması projesinde derlenmiş .dll dosyasına bir başvuru ekleyin. Visual Studio kullanıyorsanız, ContentSerializationExampleControl araç kutusuna otomatik olarak eklenir.

Denetimi Araç Kutusu'ndan bir forma sürükleyin ve Özellikler penceresi listelenen nesnenin DimensionData özelliklerini ayarlayın. Formun kodunu görüntülediğinizde, kod üst formun InitializeComponent yöntemine eklenmiş olur. Bu kod, denetimin özelliklerinin değerlerini tasarım modunda ayarladığınız özelliklere ayarlar.

#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

Açıklamalar

Seri hale getirici bir tasarım modu belgesinin kalıcı durumunu kalıcı hale getirdiğinde, genellikle tasarım zamanında ayarlanmış özelliklerin değerlerini kalıcı hale getirmek için bileşenlerin başlatma yöntemine kod ekler. Başka bir davranışı yönlendirmek üzere ayarlanmış bir öznitelik yoksa, bu durum çoğu temel tür için varsayılan olarak gerçekleşir.

ile, bir özelliğin DesignerSerializationVisibilityAttributeVisibledeğerinin , ve başlatma kodunda kalıcı olmasını ve başlatma kodunda Hiddenkalıcı olmaması gerektiğini veya özelliğine atanan nesnenin gizli özelliği için değil, her genel için başlatma kodu oluşturulması gereken öğesinden oluşurContent.

'a sahip DesignerSerializationVisibilityAttribute olmayan üyeler, değerine Visiblesahip bir'e sahipmiş DesignerSerializationVisibilityAttribute gibi kabul edilir. olarak Visible işaretlenmiş bir özelliğin değerleri, türü için bir seri hale getirici tarafından mümkünse serileştirilir. Belirli bir tür veya özellik için özel serileştirme belirtmek için kullanın DesignerSerializerAttribute.

Daha fazla bilgi için bkz . Öznitelikler.

Oluşturucular

DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility)

Belirtilen DesignerSerializationVisibility değeri kullanarak sınıfının yeni bir örneğini DesignerSerializationVisibilityAttribute başlatır.

Alanlar

Content

Bir seri hale getiricinin özelliğin kendisi yerine özelliğin içeriğini seri hale getirmesi gerektiğini belirtir. Bu alan salt okunur durumdadır.

Default

Varsayılan değeri belirtir, Visibleyani görsel tasarımcı bir özelliğin değerini oluşturmak için varsayılan kuralları kullanır. Bu static alan salt okunur.

Hidden

Bir seri hale getirici özelliğinin değerini seri hale getirmemesi gerektiğini belirtir. Bu static alan salt okunur.

Visible

Bir seri hale getirici özelliğinin değerini seri hale getirmek için izin verilmesi gerektiğini belirtir. Bu static alan salt okunur.

Özellikler

TypeId

Türetilmiş bir sınıfta uygulandığında, bu Attributeiçin benzersiz bir tanımlayıcı alır.

(Devralındığı yer: Attribute)
Visibility

Seri hale getiricinin bir özelliğin değerinin kalıcı olup olmadığını ve nasıl kalıcı hale getirildiğini belirlerken kullanması gereken temel serileştirme modunu belirten bir değer alır.

Yöntemler

Equals(Object)

Bu örnek ile belirtilen bir nesnenin eşit olup olmadığını gösterir.

GetHashCode()

Bu nesnenin karma kodunu döndürür.

GetType()

Type Geçerli örneğini alır.

(Devralındığı yer: Object)
IsDefaultAttribute()

Özniteliğin geçerli değerinin öznitelik için varsayılan değer olup olmadığını belirten bir değer alır.

IsDefaultAttribute()

Türetilmiş bir sınıfta geçersiz kılındığında, bu örneğin değerinin türetilmiş sınıf için varsayılan değer olup olmadığını gösterir.

(Devralındığı yer: Attribute)
Match(Object)

Türetilmiş bir sınıfta geçersiz kılındığında, bu örneğin belirtilen bir nesneye eşit olup olmadığını gösteren bir değer döndürür.

(Devralındığı yer: Attribute)
MemberwiseClone()

Geçerli Objectöğesinin sığ bir kopyasını oluşturur.

(Devralındığı yer: Object)
ToString()

Geçerli nesneyi temsil eden dizeyi döndürür.

(Devralındığı yer: Object)

Belirtik Arabirim Kullanımları

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

Bir ad kümesini karşılık gelen bir dağıtma tanımlayıcısı kümesine eşler.

(Devralındığı yer: Attribute)
_Attribute.GetTypeInfo(UInt32, UInt32, IntPtr)

Bir arabirimin tür bilgilerini almak için kullanılabilecek bir nesnenin tür bilgilerini alır.

(Devralındığı yer: Attribute)
_Attribute.GetTypeInfoCount(UInt32)

Bir nesnenin sağladığı tür bilgisi arabirimlerinin sayısını alır (0 ya da 1).

(Devralındığı yer: Attribute)
_Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

Bir nesne tarafından sunulan özelliklere ve yöntemlere erişim sağlar.

(Devralındığı yer: Attribute)

Şunlara uygulanır

Ayrıca bkz.