Edit

Share via


TypeDescriptor Class

Definition

Provides information about the characteristics for a component, such as its attributes, properties, and events. This class cannot be inherited.

public ref class TypeDescriptor sealed
public sealed class TypeDescriptor
type TypeDescriptor = class
Public NotInheritable Class TypeDescriptor
Inheritance
TypeDescriptor

Remarks

The .NET Framework provides two ways to access metadata on a type: the reflection API provided in the System.Reflection namespace, and the TypeDescriptor class. Reflection is a general mechanism available to all types because its foundation is established in the GetType method of the root Object class. The information it returns for a type is not extensible, in that it cannot be modified after compilation of the target type. For more information, see the topics in Reflection.

In contrast, TypeDescriptor is an extensible inspection mechanism for components: those classes that implement the IComponent interface. Unlike reflection, it does not inspect for methods. TypeDescriptor can be dynamically extended by several services available through the target component's Site. The following table shows these services.

Service name Description
IExtenderProvider Enables another class, such as ToolTip, to provide extra properties to a component.
ITypeDescriptorFilterService Enables another object to modify the standard metadata that is exposed by a component.
ICustomTypeDescriptor Enables a class to completely and dynamically specify its own metadata, replacing the standard inspection mechanism of TypeDescriptor.

The extensibility provided by TypeDescriptor allows the design-time representation of a component to differ from its actual run-time representation, which makes TypeDescriptor useful for building design-time infrastructure.

All the methods in TypeDescriptor are static. You cannot create an instance of this class, and this class cannot be inherited.

You can set property and event values two different ways: specify them in the component class or change them at design time. Because you can set these values two ways, the overloaded methods of TypeDescriptor take two different types of parameters: a class type or an object instance.

When you want to access TypeDescriptor information and you have an instance of the object, use the method that calls for a component. Use the method that calls for the class type only when you do not have an instance of the object.

Properties and events are cached by TypeDescriptor for speed. Typically, they are constant for the lifetime of an object. However, extender providers and designers can change the set of properties on an object. If this is the case, then the Refresh method must be called to update the cache.

Properties

ComNativeDescriptorHandler
Obsolete.
Obsolete.
Obsolete.
Obsolete.

Gets or sets the provider for the Component Object Model (COM) type information for the target component.

ComObjectType

Gets the type of the Component Object Model (COM) object represented by the target component.

InterfaceType

Gets a type that represents a type description provider for all interface types.

Methods

AddAttributes(Object, Attribute[])

Adds class-level attributes to the target component instance.

AddAttributes(Type, Attribute[])

Adds class-level attributes to the target component type.

AddEditorTable(Type, Hashtable)

Adds an editor table for the given editor base type.

AddProvider(TypeDescriptionProvider, Object)

Adds a type description provider for a single instance of a component.

AddProvider(TypeDescriptionProvider, Type)

Adds a type description provider for a component class.

AddProviderTransparent(TypeDescriptionProvider, Object)

Adds a type description provider for a single instance of a component.

AddProviderTransparent(TypeDescriptionProvider, Type)

Adds a type description provider for a component class.

CreateAssociation(Object, Object)

Creates a primary-secondary association between two objects.

CreateDesigner(IComponent, Type)

Creates an instance of the designer associated with the specified component and of the specified type of designer.

CreateEvent(Type, EventDescriptor, Attribute[])

Creates a new event descriptor that is identical to an existing event descriptor, when passed the existing EventDescriptor.

CreateEvent(Type, String, Type, Attribute[])

Creates a new event descriptor that is identical to an existing event descriptor by dynamically generating descriptor information from a specified event on a type.

CreateInstance(IServiceProvider, Type, Type[], Object[])

Creates an object that can substitute for another data type.

CreateProperty(Type, PropertyDescriptor, Attribute[])

Creates a new property descriptor from an existing property descriptor, using the specified existing PropertyDescriptor and attribute array.

CreateProperty(Type, String, Type, Attribute[])

Creates and dynamically binds a property descriptor to a type, using the specified property name, type, and attribute array.

Equals(Object)

Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetAssociation(Type, Object)

Returns an instance of the type associated with the specified primary object.

GetAttributes(Object)

Returns the collection of attributes for the specified component.

GetAttributes(Object, Boolean)

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

GetAttributes(Type)

Returns a collection of attributes for the specified type of component.

GetClassName(Object)

Returns the name of the class for the specified component using the default type descriptor.

GetClassName(Object, Boolean)

Returns the name of the class for the specified component using a custom type descriptor.

GetClassName(Type)

Returns the name of the class for the specified type.

GetComponentName(Object)

Returns the name of the specified component using the default type descriptor.

GetComponentName(Object, Boolean)

Returns the name of the specified component using a custom type descriptor.

GetConverter(Object)

Returns a type converter for the type of the specified component.

GetConverter(Object, Boolean)

Returns a type converter for the type of the specified component with a custom type descriptor.

GetConverter(Type)

Returns a type converter for the specified type.

GetConverterFromRegisteredType(Object)

Gets a type converter for the type of the specified component.

GetConverterFromRegisteredType(Type)

Gets a type converter for the specified registered type.

GetDefaultEvent(Object)

Returns the default event for the specified component.

GetDefaultEvent(Object, Boolean)

Returns the default event for a component with a custom type descriptor.

GetDefaultEvent(Type)

Returns the default event for the specified type of component.

GetDefaultProperty(Object)

Returns the default property for the specified component.

GetDefaultProperty(Object, Boolean)

Returns the default property for the specified component with a custom type descriptor.

GetDefaultProperty(Type)

Returns the default property for the specified type of component.

GetEditor(Object, Type)

Gets an editor with the specified base type for the specified component.

GetEditor(Object, Type, Boolean)

Returns an editor with the specified base type and with a custom type descriptor for the specified component.

GetEditor(Type, Type)

Returns an editor with the specified base type for the specified type.

GetEvents(Object)

Returns the collection of events for the specified component.

GetEvents(Object, Attribute[])

Returns the collection of events for a specified component using a specified array of attributes as a filter.

GetEvents(Object, Attribute[], Boolean)

Returns the collection of events for a specified component using a specified array of attributes as a filter and using a custom type descriptor.

GetEvents(Object, Boolean)

Returns the collection of events for a specified component with a custom type descriptor.

GetEvents(Type)

Returns the collection of events for a specified type of component.

GetEvents(Type, Attribute[])

Returns the collection of events for a specified type of component using a specified array of attributes as a filter.

GetEventsFromRegisteredType(Type)

Gets a collection of events for a specified type of component.

GetFullComponentName(Object)

Returns the fully qualified name of the component.

GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetProperties(Object)

Returns the collection of properties for a specified component.

GetProperties(Object, Attribute[])

Returns the collection of properties for a specified component using a specified array of attributes as a filter.

GetProperties(Object, Attribute[], Boolean)

Returns the collection of properties for a specified component using a specified array of attributes as a filter and using a custom type descriptor.

GetProperties(Object, Boolean)

Returns the collection of properties for a specified component using the default type descriptor.

GetProperties(Type)

Returns the collection of properties for a specified type of component.

GetProperties(Type, Attribute[])

Returns the collection of properties for a specified type of component using a specified array of attributes as a filter.

GetPropertiesFromRegisteredType(Object)

Gets a collection of properties for a specified component.

GetPropertiesFromRegisteredType(Type)

Gets a collection of properties for a specified type.

GetProvider(Object)

Returns the type description provider for the specified component.

GetProvider(Type)

Returns the type description provider for the specified type.

GetReflectionType(Object)

Returns a Type that can be used to perform reflection, given an object.

GetReflectionType(Type)

Returns a Type that can be used to perform reflection, given a class type.

GetType()

Gets the Type of the current instance.

(Inherited from Object)
MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
Refresh(Assembly)

Clears the properties and events for the specified assembly from the cache.

Refresh(Module)

Clears the properties and events for the specified module from the cache.

Refresh(Object)

Clears the properties and events for the specified component from the cache.

Refresh(Type)

Clears the properties and events for the specified type of component from the cache.

RegisterType<T>()

Registers the type so it can be used by reflection-based providers in trimmed applications.

RemoveAssociation(Object, Object)

Removes an association between two objects.

RemoveAssociations(Object)

Removes all associations for a primary object.

RemoveProvider(TypeDescriptionProvider, Object)

Removes a previously added type description provider that is associated with the specified object.

RemoveProvider(TypeDescriptionProvider, Type)

Removes a previously added type description provider that is associated with the specified type.

RemoveProviderTransparent(TypeDescriptionProvider, Object)

Removes a previously added type description provider that is associated with the specified object.

RemoveProviderTransparent(TypeDescriptionProvider, Type)

Removes a previously added type description provider that is associated with the specified type.

SortDescriptorArray(IList)

Sorts descriptors using the name of the descriptor.

ToString()

Returns a string that represents the current object.

(Inherited from Object)

Events

Refreshed

Occurs when the cache for a component is cleared.

Applies to

See also