Export (0) Print
Expand All

TypeDescriptor Class

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

System.Object
  System.ComponentModel.TypeDescriptor

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

[HostProtectionAttribute(SecurityAction.LinkDemand, SharedState = true)]
public sealed class TypeDescriptor

The TypeDescriptor type exposes the following members.

  NameDescription
Public propertyStatic memberComNativeDescriptorHandlerInfrastructure. Obsolete. Gets or sets the provider for the Component Object Model (COM) type information for the target component.
Public propertyStatic memberComObjectTypeGets the type of the Component Object Model (COM) object represented by the target component.
Public propertyStatic memberInterfaceTypeGets a type that represents a type description provider for all interface types.
Top

  NameDescription
Public methodStatic memberAddAttributes(Object, Attribute[])Adds class-level attributes to the target component instance.
Public methodStatic memberAddAttributes(Type, Attribute[])Adds class-level attributes to the target component type.
Public methodStatic memberAddEditorTableAdds an editor table for the given editor base type.
Public methodStatic memberAddProvider(TypeDescriptionProvider, Object)Adds a type description provider for a single instance of a component.
Public methodStatic memberAddProvider(TypeDescriptionProvider, Type)Adds a type description provider for a component class.
Public methodStatic memberAddProviderTransparent(TypeDescriptionProvider, Object)Adds a type description provider for a single instance of a component.
Public methodStatic memberAddProviderTransparent(TypeDescriptionProvider, Type)Adds a type description provider for a component class.
Public methodStatic memberCreateAssociationCreates a primary-secondary association between two objects.
Public methodStatic memberCreateDesignerCreates an instance of the designer associated with the specified component and of the specified type of designer.
Public methodStatic memberCreateEvent(Type, EventDescriptor, Attribute[])Creates a new event descriptor that is identical to an existing event descriptor, when passed the existing EventDescriptor.
Public methodStatic memberCreateEvent(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 methodStatic memberCreateInstanceCreates an object that can substitute for another data type.
Public methodStatic memberCreateProperty(Type, PropertyDescriptor, Attribute[])Creates a new property descriptor from an existing property descriptor, using the specified existing PropertyDescriptor and attribute array.
Public methodStatic memberCreateProperty(Type, String, Type, Attribute[])Creates and dynamically binds a property descriptor to a type, using the specified property name, type, and attribute array.
Public methodSupported by the XNA FrameworkEquals(Object)Determines whether the specified object is equal to the current object. (Inherited from Object.)
Public methodStatic memberGetAssociationReturns an instance of the type associated with the specified primary object.
Public methodStatic memberGetAttributes(Object)Returns the collection of attributes for the specified component.
Public methodStatic memberGetAttributes(Type)Returns a collection of attributes for the specified type of component.
Public methodStatic memberGetAttributes(Object, Boolean)Returns a collection of attributes for the specified component and a Boolean indicating that a custom type descriptor has been created.
Public methodStatic memberGetClassName(Object)Returns the name of the class for the specified component using the default type descriptor.
Public methodStatic memberGetClassName(Type)Returns the name of the class for the specified type.
Public methodStatic memberGetClassName(Object, Boolean)Returns the name of the class for the specified component using a custom type descriptor.
Public methodStatic memberGetComponentName(Object)Returns the name of the specified component using the default type descriptor.
Public methodStatic memberGetComponentName(Object, Boolean)Returns the name of the specified component using a custom type descriptor.
Public methodStatic memberGetConverter(Object)Returns a type converter for the type of the specified component.
Public methodStatic memberGetConverter(Type)Returns a type converter for the specified type.
Public methodStatic memberGetConverter(Object, Boolean)Returns a type converter for the type of the specified component with a custom type descriptor.
Public methodStatic memberGetDefaultEvent(Object)Returns the default event for the specified component.
Public methodStatic memberGetDefaultEvent(Type)Returns the default event for the specified type of component.
Public methodStatic memberGetDefaultEvent(Object, Boolean)Returns the default event for a component with a custom type descriptor.
Public methodStatic memberGetDefaultProperty(Object)Returns the default property for the specified component.
Public methodStatic memberGetDefaultProperty(Type)Returns the default property for the specified type of component.
Public methodStatic memberGetDefaultProperty(Object, Boolean)Returns the default property for the specified component with a custom type descriptor.
Public methodStatic memberGetEditor(Object, Type)Gets an editor with the specified base type for the specified component.
Public methodStatic memberGetEditor(Type, Type)Returns an editor with the specified base type for the specified type.
Public methodStatic memberGetEditor(Object, Type, Boolean)Returns an editor with the specified base type and with a custom type descriptor for the specified component.
Public methodStatic memberSupported by the XNA FrameworkGetEvents(Object)Returns the collection of events for the specified component.
Public methodStatic memberSupported by the XNA FrameworkGetEvents(Type)Returns the collection of events for a specified type of component.
Public methodStatic memberSupported by the XNA FrameworkGetEvents(Object, Attribute[])Returns the collection of events for a specified component using a specified array of attributes as a filter.
Public methodStatic memberSupported by the XNA FrameworkGetEvents(Object, Boolean)Returns the collection of events for a specified component with a custom type descriptor.
Public methodStatic memberSupported by the XNA FrameworkGetEvents(Type, Attribute[])Returns the collection of events for a specified type of component using a specified array of attributes as a filter.
Public methodStatic memberSupported by the XNA FrameworkGetEvents(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 methodStatic memberGetFullComponentNameReturns the fully qualified name of the component.
Public methodSupported by the XNA FrameworkGetHashCodeServes as the default hash function. (Inherited from Object.)
Public methodStatic memberSupported by the XNA FrameworkGetProperties(Object)Returns the collection of properties for a specified component.
Public methodStatic memberSupported by the XNA FrameworkGetProperties(Type)Returns the collection of properties for a specified type of component.
Public methodStatic memberGetProperties(Object, Attribute[])Returns the collection of properties for a specified component using a specified array of attributes as a filter.
Public methodStatic memberSupported by the XNA FrameworkGetProperties(Object, Boolean)Returns the collection of properties for a specified component using the default type descriptor.
Public methodStatic memberGetProperties(Type, Attribute[])Returns the collection of properties for a specified type of component using a specified array of attributes as a filter.
Public methodStatic memberGetProperties(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 methodStatic memberGetProvider(Object)Returns the type description provider for the specified component.
Public methodStatic memberGetProvider(Type)Returns the type description provider for the specified type.
Public methodStatic memberGetReflectionType(Object)Returns a Type that can be used to perform reflection, given an object.
Public methodStatic memberGetReflectionType(Type)Returns a Type that can be used to perform reflection, given a class type.
Public methodSupported by the XNA FrameworkGetTypeGets the Type of the current instance. (Inherited from Object.)
Public methodStatic memberRefresh(Assembly)Clears the properties and events for the specified assembly from the cache.
Public methodStatic memberRefresh(Module)Clears the properties and events for the specified module from the cache.
Public methodStatic memberRefresh(Object)Clears the properties and events for the specified component from the cache.
Public methodStatic memberRefresh(Type)Clears the properties and events for the specified type of component from the cache.
Public methodStatic memberRemoveAssociationRemoves an association between two objects.
Public methodStatic memberRemoveAssociationsRemoves all associations for a primary object.
Public methodStatic memberRemoveProvider(TypeDescriptionProvider, Object)Removes a previously added type description provider that is associated with the specified object.
Public methodStatic memberRemoveProvider(TypeDescriptionProvider, Type)Removes a previously added type description provider that is associated with the specified type.
Public methodStatic memberRemoveProviderTransparent(TypeDescriptionProvider, Object)Removes a previously added type description provider that is associated with the specified object.
Public methodStatic memberRemoveProviderTransparent(TypeDescriptionProvider, Type)Removes a previously added type description provider that is associated with the specified type.
Public methodStatic memberSortDescriptorArraySorts descriptors using the name of the descriptor.
Public methodSupported by the XNA FrameworkToStringReturns a string that represents the current object. (Inherited from Object.)
Top

  NameDescription
Public eventStatic memberRefreshedOccurs when the cache for a component is cleared.
Top

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.

.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

Windows 8.1, Windows Server 2012 R2, 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.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Show:
© 2014 Microsoft