VirtualTypeBuilder::AttributeCollection::Add Method (Attribute^)

 
Namespace:   Microsoft.VisualStudio.Shell.Design
Assembly:  Microsoft.VisualStudio.Shell.Design (in Microsoft.VisualStudio.Shell.Design.dll)

public:
int Add(
	Attribute^ value
)

Parameters

value
Type: System::Attribute^

The Attribute to be added to the end of the collection.

Return Value

Type: System::Int32

The index at which the value has been added.

Exception Condition
ArgumentException

value cannot be placed on a class.

ArgumentNullException

The attribute is null.

Attributes are added in the order you would expect them to be declared on the class. The following code example shows how to add attributes that would be declared on a physical class.

[Browsable(true)]
[Description("Hello world")]
public class MyClass {}

The following code example shows the order in which to add attributes.

Add(new DescriptionAttribute("Hello world"));
Add(BrowsableAttribute.Yes);

Attributes that are marked as "allow multiple" will be added multiple times, while those not marked with "allow multiple" will only be added once, with the last one added taking precedence. This is in the same manner as a compiler.

Return to top
Show: