DesignerSerializationVisibilityAttribute.Visibility Özellik

Tanım

Bir 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.

public:
 property System::ComponentModel::DesignerSerializationVisibility Visibility { System::ComponentModel::DesignerSerializationVisibility get(); };
public System.ComponentModel.DesignerSerializationVisibility Visibility { get; }
member this.Visibility : System.ComponentModel.DesignerSerializationVisibility
Public ReadOnly Property Visibility As DesignerSerializationVisibility

Özellik Değeri

Değerlerden DesignerSerializationVisibility biri. Varsayılan değer: Visible.

Örnekler

Aşağıdaki kod örneği için MyPropertydeğerinin nasıl denetleneceklerini DesignerSerializationVisibilityAttribute gösterir. İlk olarak kod, nesnenin tüm özelliklerine sahip bir PropertyDescriptorCollection alır. Ardından, kod almak için dizinini PropertyDescriptorCollection oluşturur MyProperty. Ardından kod, bu özelliğin özniteliklerini döndürür ve öznitelikler değişkenine kaydeder.

Bu örnekte değerini DesignerSerializationVisibilityAttributedenetlemenin iki farklı yolu vardır. İkinci kod parçasında, örnek yöntemini bir static değerle çağırırEquals. Son kod parçasında örnek, değerini denetlemek için özelliğini kullanır Visibility .

// Gets the attributes for the property.
AttributeCollection^ attributes = TypeDescriptor::GetProperties( this )[ "MyProperty" ]->Attributes;

// Checks to see if the value of the DesignerSerializationVisibilityAttribute is set to Content.
if ( attributes[ DesignerSerializationVisibilityAttribute::typeid ]->Equals( DesignerSerializationVisibilityAttribute::Content ) )
{
   // Insert code here.
}


// This is another way to see whether the property is marked as serializing content.
DesignerSerializationVisibilityAttribute^ myAttribute = dynamic_cast<DesignerSerializationVisibilityAttribute^>(attributes[ DesignerSerializationVisibilityAttribute::typeid ]);
if ( myAttribute->Visibility == DesignerSerializationVisibility::Content )
{
   // Insert code here.
}
// Gets the attributes for the property.
 AttributeCollection attributes = 
    TypeDescriptor.GetProperties(this)["MyProperty"].Attributes;
 
 // Checks to see if the value of the DesignerSerializationVisibilityAttribute is set to Content.
 if(attributes[typeof(DesignerSerializationVisibilityAttribute)].Equals(DesignerSerializationVisibilityAttribute.Content)) {
    // Insert code here.
 }
 
 // This is another way to see whether the property is marked as serializing content.
 DesignerSerializationVisibilityAttribute myAttribute = 
    (DesignerSerializationVisibilityAttribute)attributes[typeof(DesignerSerializationVisibilityAttribute)];
 if(myAttribute.Visibility == DesignerSerializationVisibility.Content) {
    // Insert code here.
 }
' Gets the attributes for the property.
Dim attributes As AttributeCollection = _
    TypeDescriptor.GetProperties(Me)("MyProperty").Attributes

' Checks to see if the value of the DesignerSerializationVisibilityAttribute
' is set to Content.
If attributes(GetType(DesignerSerializationVisibilityAttribute)).Equals( _
    DesignerSerializationVisibilityAttribute.Content) Then
    ' Insert code here.
End If 

' This is another way to see whether the property is marked as serializing content.
Dim myAttribute As DesignerSerializationVisibilityAttribute = _
    CType(attributes(GetType(DesignerSerializationVisibilityAttribute)), _
    DesignerSerializationVisibilityAttribute)
If myAttribute.Visibility = DesignerSerializationVisibility.Content Then
    ' Insert code here.
End If

Şunlara uygulanır

Ayrıca bkz.