Skip to main content
.NET Framework Class Library
TypeDescriptor Class

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

Inheritance Hierarchy
SystemObject
  System.ComponentModelTypeDescriptor

Namespace:   System.ComponentModel
Assembly:  System (in System.dll)
Syntax
<[%$TOPIC/7z7xccyw_en-us_VS_110_2_0_0_0_0%]([%$TOPIC/7z7xccyw_en-us_VS_110_2_0_0_0_1%].LinkDemand, SharedState := True)> _
Public NotInheritable Class TypeDescriptor
[[%$TOPIC/7z7xccyw_en-us_VS_110_2_0_1_0_0%]([%$TOPIC/7z7xccyw_en-us_VS_110_2_0_1_0_1%].LinkDemand, SharedState = true)]
public sealed class TypeDescriptor
[[%$TOPIC/7z7xccyw_en-us_VS_110_2_0_2_0_0%]([%$TOPIC/7z7xccyw_en-us_VS_110_2_0_2_0_1%]::LinkDemand, SharedState = true)]
public ref class TypeDescriptor sealed
[<[%$TOPIC/7z7xccyw_en-us_VS_110_2_0_3_0_0%]>]
[<[%$TOPIC/7z7xccyw_en-us_VS_110_2_0_3_0_1%]([%$TOPIC/7z7xccyw_en-us_VS_110_2_0_3_0_2%].LinkDemand, SharedState = true)>]
type TypeDescriptor =  class end

The TypeDescriptor type exposes the following members.

Properties
  NameDescription
Public property Static member ComNativeDescriptorHandlerInfrastructure. Obsolete. Gets or sets the provider for the Component Object Model (COM) type information for the target component.
Public property Static member ComObjectTypeGets the type of the Component Object Model (COM) object represented by the target component.
Public property Static member InterfaceTypeGets a type that represents a type description provider for all interface types.
Top
Methods
  NameDescription
Public method Static member AddAttributes(Object, Attribute)Adds class-level attributes to the target component instance.
Public method Static member AddAttributes(Type, Attribute)Adds class-level attributes to the target component type.
Public method Static member AddEditorTableAdds an editor table for the given editor base type.
Public method Static member AddProvider(TypeDescriptionProvider, Object)Adds a type description provider for a single instance of a component.
Public method Static member AddProvider(TypeDescriptionProvider, Type)Adds a type description provider for a component class.
Public method Static member AddProviderTransparent(TypeDescriptionProvider, Object)Adds a type description provider for a single instance of a component.
Public method Static member AddProviderTransparent(TypeDescriptionProvider, Type)Adds a type description provider for a component class.
Public method Static member CreateAssociationCreates a primary-secondary association between two objects.
Public method Static member CreateDesignerCreates an instance of the designer associated with the specified component and of the specified type of designer.
Public method Static member CreateEvent(Type, EventDescriptor, Attribute)Creates a new event descriptor that is identical to an existing event descriptor, when passed the existing EventDescriptor.
Public method Static member 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.
Public method Static member CreateInstanceCreates an object that can substitute for another data type.
Public method Static member CreateProperty(Type, PropertyDescriptor, Attribute)Creates a new property descriptor from an existing property descriptor, using the specified existing PropertyDescriptor and attribute array.
Public method Static member CreateProperty(Type, String, Type, Attribute)Creates and dynamically binds a property descriptor to a type, using the specified property name, type, and attribute array.
Public method Supported by the XNA Framework Equals(Object)Determines whether the specified object is equal to the current object. (Inherited from Object.)
Public method Static member GetAssociationReturns an instance of the type associated with the specified primary object.
Public method Static member GetAttributes(Object)Returns the collection of attributes for the specified component.
Public method Static member GetAttributes(Type)Returns a collection of attributes for the specified type of component.
Public method Static member GetAttributes(Object, Boolean)Returns a collection of attributes for the specified component and a Boolean indicating that a custom type descriptor has been created.
Public method Static member GetClassName(Object)Returns the name of the class for the specified component using the default type descriptor.
Public method Static member GetClassName(Type)Returns the name of the class for the specified type.
Public method Static member GetClassName(Object, Boolean)Returns the name of the class for the specified component using a custom type descriptor.
Public method Static member GetComponentName(Object)Returns the name of the specified component using the default type descriptor.
Public method Static member GetComponentName(Object, Boolean)Returns the name of the specified component using a custom type descriptor.
Public method Static member GetConverter(Object)Returns a type converter for the type of the specified component.
Public method Static member GetConverter(Type)Returns a type converter for the specified type.
Public method Static member GetConverter(Object, Boolean)Returns a type converter for the type of the specified component with a custom type descriptor.
Public method Static member GetDefaultEvent(Object)Returns the default event for the specified component.
Public method Static member GetDefaultEvent(Type)Returns the default event for the specified type of component.
Public method Static member GetDefaultEvent(Object, Boolean)Returns the default event for a component with a custom type descriptor.
Public method Static member GetDefaultProperty(Object)Returns the default property for the specified component.
Public method Static member GetDefaultProperty(Type)Returns the default property for the specified type of component.
Public method Static member GetDefaultProperty(Object, Boolean)Returns the default property for the specified component with a custom type descriptor.
Public method Static member GetEditor(Object, Type)Gets an editor with the specified base type for the specified component.
Public method Static member GetEditor(Type, Type)Returns an editor with the specified base type for the specified type.
Public method Static member GetEditor(Object, Type, Boolean)Returns an editor with the specified base type and with a custom type descriptor for the specified component.
Public method Static member Supported by the XNA Framework GetEvents(Object)Returns the collection of events for the specified component.
Public method Static member Supported by the XNA Framework GetEvents(Type)Returns the collection of events for a specified type of component.
Public method Static member Supported by the XNA Framework GetEvents(Object, Attribute)Returns the collection of events for a specified component using a specified array of attributes as a filter.
Public method Static member Supported by the XNA Framework GetEvents(Object, Boolean)Returns the collection of events for a specified component with a custom type descriptor.
Public method Static member Supported by the XNA Framework GetEvents(Type, Attribute)Returns the collection of events for a specified type of component using a specified array of attributes as a filter.
Public method Static member Supported by the XNA Framework 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.
Public method Static member GetFullComponentNameReturns the fully qualified name of the component.
Public method Supported by the XNA Framework GetHashCodeServes as a hash function for a particular type. (Inherited from Object.)
Public method Static member Supported by the XNA Framework GetProperties(Object)Returns the collection of properties for a specified component.
Public method Static member Supported by the XNA Framework GetProperties(Type)Returns the collection of properties for a specified type of component.
Public method Static member GetProperties(Object, Attribute)Returns the collection of properties for a specified component using a specified array of attributes as a filter.
Public method Static member Supported by the XNA Framework GetProperties(Object, Boolean)Returns the collection of properties for a specified component using the default type descriptor.
Public method Static member GetProperties(Type, Attribute)Returns the collection of properties for a specified type of component using a specified array of attributes as a filter.
Public method Static member 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.
Public method Static member GetProvider(Object)Returns the type description provider for the specified component.
Public method Static member GetProvider(Type)Returns the type description provider for the specified type.
Public method Static member GetReflectionType(Object)Returns a Type that can be used to perform reflection, given an object.
Public method Static member GetReflectionType(Type)Returns a Type that can be used to perform reflection, given a class type.
Public method Supported by the XNA Framework GetTypeGets the Type of the current instance. (Inherited from Object.)
Public method Static member Refresh(Assembly)Clears the properties and events for the specified assembly from the cache.
Public method Static member Refresh(Module)Clears the properties and events for the specified module from the cache.
Public method Static member Refresh(Object)Clears the properties and events for the specified component from the cache.
Public method Static member Refresh(Type)Clears the properties and events for the specified type of component from the cache.
Public method Static member RemoveAssociationRemoves an association between two objects.
Public method Static member RemoveAssociationsRemoves all associations for a primary object.
Public method Static member RemoveProvider(TypeDescriptionProvider, Object)Removes a previously added type description provider that is associated with the specified object.
Public method Static member RemoveProvider(TypeDescriptionProvider, Type)Removes a previously added type description provider that is associated with the specified type.
Public method Static member RemoveProviderTransparent(TypeDescriptionProvider, Object)Removes a previously added type description provider that is associated with the specified object.
Public method Static member RemoveProviderTransparent(TypeDescriptionProvider, Type)Removes a previously added type description provider that is associated with the specified type.
Public method Static member SortDescriptorArraySorts descriptors using the name of the descriptor.
Public method Supported by the XNA Framework ToStringReturns a string that represents the current object. (Inherited from Object.)
Top
Events
  NameDescription
Public event Static member RefreshedOccurs when the cache for a component is cleared.
Top
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 the .NET Framework.

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.

NoteNote

The HostProtectionAttribute attribute applied to this type or member has the following Resources property value: SharedState. The HostProtectionAttribute does not affect desktop applications (which are typically started by double-clicking an icon, typing a command, or entering a URL in a browser). For more information, see the HostProtectionAttribute class or SQL Server Programming and Host Protection Attributes.

Version Information

.NET Framework

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

.NET Framework Client Profile

Supported in: 4, 3.5 SP1
Platforms

Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Thread Safety
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.