DesignerSerializationVisibilityAttribute.Visibility Property
Gets a value indicating the basic serialization mode a serializer should use when determining whether and how to persist the value of a property.
Assembly: System (in System.dll)
Property Value
Type: System.ComponentModel.DesignerSerializationVisibilityOne of the DesignerSerializationVisibility values. The default is Visible.
The following code example shows how to check the value of the DesignerSerializationVisibilityAttribute for MyProperty. First the code gets a PropertyDescriptorCollection with all the properties for the object. Next, the code indexes into the PropertyDescriptorCollection to get MyProperty. Then, the code returns the attributes for this property and saves them in the attributes variable.
This example presents two different ways to check the value of the DesignerSerializationVisibilityAttribute. In the second code fragment, the example calls the Equals method with a static value. In the last code fragment, the example uses the Visibility property to check the value.
// 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. }
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.