Windows apps
Collapse the table of content
Expand the table of content
Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

TypeDescriptor.GetAttributes Method (Object)

 
System_CAPS_noteNote

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Returns the collection of attributes for the specified component.

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

public static AttributeCollection GetAttributes(
	object component
)

Parameters

component
Type: System.Object

The component for which you want to get attributes.

Return Value

Type: System.ComponentModel.AttributeCollection

An AttributeCollection containing the attributes for the component. If component is null, this method returns an empty collection.

The attributes returned by the GetAttributes method may be dynamically modified from the original component's source listing by extender providers (IExtenderProvider), filter services (ITypeDescriptorFilterService), and attribute filters.

When you define a custom attribute with AttributeUsageAttribute.AllowMultiple set to true, you must override the Attribute.TypeId property to make it unique. If all instances of your attribute are unique, override Attribute.TypeId to return the object identity of your attribute. If only some instances of your attribute are unique, return a value from Attribute.TypeId that would return equality in those cases. For example, some attributes have a constructor parameter that acts as a unique key. For these attributes, return the value of the constructor parameter from the Attribute.TypeId property.

System_CAPS_noteNote

The default implementation of Attribute.TypeId returns the type identity regardless of the value of the AttributeUsageAttribute.AllowMultiple property. In order to return multiple instances of an AttributeUsageAttribute.AllowMultiple attribute from the AttributeCollection, your attribute must override the Attribute.TypeId property.

For an example of this method, see the Matches method.

.NET Framework
Available since 1.1
Return to top
Show:
© 2018 Microsoft