DesignerSerializationVisibilityAttribute.Visibility Eigenschaft
Definition
Wichtig
Einige Informationen beziehen sich auf Vorabversionen, die vor dem Release ggf. grundlegend überarbeitet werden. Microsoft übernimmt hinsichtlich der hier bereitgestellten Informationen keine Gewährleistungen, seien sie ausdrücklich oder konkludent.
Ruft einen Wert ab, der den grundlegenden Serialisierungsmodus angibt, den ein Serialisierer verwenden soll, wenn bestimmt wird, ob und wie der Wert einer Eigenschaft beibehalten werden soll.
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
Eigenschaftswert
Einer der DesignerSerializationVisibility Werte. Der Standardwert lautet Visible.
Beispiele
Im folgenden Codebeispiel wird veranschaulicht, wie der Wert der DesignerSerializationVisibilityAttribute Datei überprüft MyPropertywird. Zuerst ruft der Code eine PropertyDescriptorCollection mit allen Eigenschaften für das Objekt ab. Als Nächstes wird der Code indiziert PropertyDescriptorCollection , um abzurufen MyProperty. Anschließend gibt der Code die Attribute für diese Eigenschaft zurück und speichert sie in der Attributvariable.
In diesem Beispiel werden zwei verschiedene Möglichkeiten zum Überprüfen des Werts der DesignerSerializationVisibilityAttribute. Im zweiten Codefragment ruft das Beispiel die Equals Methode mit einem static Wert auf. Im letzten Codefragment verwendet das Beispiel die Visibility Eigenschaft, um den Wert zu überprüfen.
// 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