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.

Namespace:   System.ComponentModel
Assembly:  System (in System.dll)

public:
property DesignerSerializationVisibility Visibility {
	DesignerSerializationVisibility get();
}

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[ 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.
}

.NET Framework
Available since 1.1
Return to top
Show: