DesignerSerializationVisibilityAttribute.Visibility Tulajdonság

Definíció

Egy olyan értéket kap, amely azt jelzi, hogy a szerializálónak milyen alapszintű szerializálási módot kell használnia annak meghatározásához, hogy egy tulajdonság értéke megőrizve van-e és hogyan.

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

Tulajdonság értéke

Az egyik DesignerSerializationVisibility érték. Az alapértelmezett érték a Visible.

Példák

Az alábbi példakód bemutatja, hogyan ellenőrizheti a for DesignerSerializationVisibilityAttributeértékétMyProperty. Először a kód lekéri PropertyDescriptorCollection az objektum összes tulajdonságát. Ezután a kód indexel a PropertyDescriptorCollection lekéréshez MyProperty. Ezután a kód visszaadja a tulajdonság attribútumait, és menti őket az attribútumváltozóba.

Ez a példa két különböző módszert mutat be az érték DesignerSerializationVisibilityAttributeellenőrzésére. A második kódrészletben a példa egy értékkel hívja meg a Equals metódust static . Az utolsó kódrészletben a példa a Visibility tulajdonságot használja az érték ellenőrzéséhez.

// 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

A következőre érvényes:

Lásd még