This documentation is archived and is not being maintained.

TypeDescriptor.GetAttributes Method (Object, Boolean)

Returns a collection of attributes for the specified component and a Boolean indicating that a custom type descriptor has been created.

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

public static AttributeCollection GetAttributes(
	Object component,
	bool noCustomTypeDesc
)

Parameters

component
Type: System.Object
The component for which you want to get attributes.
noCustomTypeDesc
Type: System.Boolean
true to use a baseline set of attributes from the custom type descriptor if component is of type ICustomTypeDescriptor; otherwise, false.

Return Value

Type: System.ComponentModel.AttributeCollection
An AttributeCollection with the attributes for the component. If the component is null, this method returns an empty collection.

The attributes returned by the GetAttributes method may be dynamically modified from the original components 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.

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.

.NET Framework

Supported in: 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

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.
Show: