TypeDescriptor.AddAttributes Method

Definition

Adds class-level attributes to the target component.

Overloads

AddAttributes(Object, Attribute[])

Adds class-level attributes to the target component instance.

AddAttributes(Type, Attribute[])

Adds class-level attributes to the target component type.

AddAttributes(Object, Attribute[])

Source:
TypeDescriptor.cs
Source:
TypeDescriptor.cs
Source:
TypeDescriptor.cs

Adds class-level attributes to the target component instance.

public static System.ComponentModel.TypeDescriptionProvider AddAttributes (object instance, params Attribute[] attributes);

Parameters

instance
Object

An instance of the target component.

attributes
Attribute[]

An array of Attribute objects to add to the component's class.

Returns

The newly created TypeDescriptionProvider that was used to add the specified attributes.

Exceptions

One or both of the parameters is null.

Remarks

The AddAttributes(Object, Attribute[]) method adds class-level attributes to the specified instance of a component. Because this is a common requirement of applications using the Visual Studio Windows Forms Designer and Properties window, this method provides a shortcut by creating a type description provider that merges the provided attributes with the attributes that already exist on the class. The return value is the type description provider that was used to add the attributes. This provider can later be passed to the RemoveProvider(TypeDescriptionProvider, Object) method when the added attributes are no longer needed.

See also

Applies to

.NET 9 and other versions
Product Versions
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7 (package-provided), 4.7, 4.7.1 (package-provided), 4.7.1, 4.7.2 (package-provided), 4.7.2, 4.8 (package-provided), 4.8, 4.8.1
.NET Standard 2.0, 2.1

AddAttributes(Type, Attribute[])

Source:
TypeDescriptor.cs
Source:
TypeDescriptor.cs
Source:
TypeDescriptor.cs

Adds class-level attributes to the target component type.

public static System.ComponentModel.TypeDescriptionProvider AddAttributes (Type type, params Attribute[] attributes);

Parameters

type
Type

The Type of the target component.

attributes
Attribute[]

An array of Attribute objects to add to the component's class.

Returns

The newly created TypeDescriptionProvider that was used to add the specified attributes.

Exceptions

One or both of the parameters is null.

Remarks

The AddAttributes(Type, Attribute[]) method adds class-level attributes to the specified type of a component. Because this is a common requirement of applications using the Visual Studio Windows Forms Designer and Properties window, this method provides a shortcut by creating a type description provider that merges the provided attributes with the attributes that already exist on the class. The return value is the type description provider that was used to add the attributes. This provider can later be passed to the RemoveProvider(TypeDescriptionProvider, Type) method when the added attributes are no longer needed.

See also

Applies to

.NET 9 and other versions
Product Versions
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7 (package-provided), 4.7, 4.7.1 (package-provided), 4.7.1, 4.7.2 (package-provided), 4.7.2, 4.8 (package-provided), 4.8, 4.8.1
.NET Standard 2.0, 2.1