Hinweis
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, sich anzumelden oder das Verzeichnis zu wechseln.
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, das Verzeichnis zu wechseln.
Ruft einen Wert ab, der den grundlegenden Serialisierungsmodus angibt, den ein Serialisierungsprogramm verwenden soll, wenn bestimmt wird, ob und wie der Wert einer Eigenschaft beibehalten wird.
Namespace: System.ComponentModel
Assembly: System (in system.dll)
Syntax
'Declaration
Public ReadOnly Property Visibility As DesignerSerializationVisibility
'Usage
Dim instance As DesignerSerializationVisibilityAttribute
Dim value As DesignerSerializationVisibility
value = instance.Visibility
public DesignerSerializationVisibility Visibility { get; }
public:
property DesignerSerializationVisibility Visibility {
DesignerSerializationVisibility get ();
}
/** @property */
public DesignerSerializationVisibility get_Visibility ()
public function get Visibility () : DesignerSerializationVisibility
Eigenschaftenwert
Einer der DesignerSerializationVisibility-Werte. Der Standardwert ist Visible.
Beispiel
Im folgenden Beispiel wird veranschaulicht, wie der Wert von DesignerSerializationVisibilityAttribute für MyProperty überprüft wird. Zunächst wird im Code eine PropertyDescriptorCollection mit allen Eigenschaften für das Objekt abgerufen. Anschließend wird im Code MyProperty über einen Index der PropertyDescriptorCollection abgerufen. Dann gibt der Code die Attribute dieser Eigenschaft zurück und speichert diese in der attributes-Variable.
Dieses Beispiel veranschaulicht zwei verschiedene Möglichkeiten zum Überprüfen des Werts von DesignerSerializationVisibilityAttribute. Im zweiten Codefragment wird im Beispiel die Equals-Methode mit einem static-Wert aufgerufen. Im letzten Codefragment wird der Wert anhand der Visibility-Eigenschaft überprüft.
' 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
// 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.
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).
get_Item("MyProperty").get_Attributes();
// Checks to see if the value of the
// DesignerSerializationVisibilityAttribute is set to Content.
if (attributes.get_Item(
DesignerSerializationVisibilityAttribute.class.ToType()).Equals(
DesignerSerializationVisibilityAttribute.Content)) {
// Insert code here.
}
// This is another way to see whether the property is marked as
// serializing content.
DesignerSerializationVisibilityAttribute myAttribute =
(DesignerSerializationVisibilityAttribute)(attributes.get_Item(
DesignerSerializationVisibilityAttribute.class.ToType()));
if (myAttribute.get_Visibility().Equals(
DesignerSerializationVisibility.Content)) {
// Insert code here.
}
Plattformen
Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.
Versionsinformationen
.NET Framework
Unterstützt in: 2.0, 1.1, 1.0
Siehe auch
Referenz
DesignerSerializationVisibilityAttribute-Klasse
DesignerSerializationVisibilityAttribute-Member
System.ComponentModel-Namespace
Attribute
PropertyDescriptor
AttributeCollection-Klasse
PropertyDescriptorCollection