TypeDescriptor TypeDescriptor TypeDescriptor TypeDescriptor Class

定义

提供有关组件特征的信息,如组件的特性、属性和事件。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
继承
TypeDescriptorTypeDescriptorTypeDescriptorTypeDescriptor

注解

.NET Framework 提供了两种方法来访问类型的元数据: System.Reflection命名空间中提供的反射 API TypeDescriptor和类。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. 反射是适用于所有类型的常规机制,因为它的基础是在GetType根类Object的方法中建立的。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.

与此相反TypeDescriptor ,是一种可扩展的组件检查机制:用于IComponent实现接口的类。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可以通过目标组件的Site多个可用服务进行动态扩展。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 启用另一个类(如ToolTip)以向组件提供额外的属性。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 使类能够完全并动态地指定其自己的元数据,同时替换的标准TypeDescriptor检查机制。Enables a class to completely and dynamically specify its own metadata, replacing the standard inspection mechanism of TypeDescriptor.

提供TypeDescriptor的扩展性允许组件的设计时表示形式不同于它的实际运行时表示形式, 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.

TypeDescriptor的所有方法都static是。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. 由于可以通过两种方式设置这些值,因此的重载TypeDescriptor方法采用两种不同类型的参数:类类型或对象实例。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.

如果要访问TypeDescriptor信息并且具有对象的实例,请使用调用组件的方法。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.

将缓存TypeDescriptor属性和事件以获得速度。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. 如果是这种情况, Refresh则必须调用方法来更新缓存。If this is the case, then the Refresh method must be called to update the cache.

属性

ComNativeDescriptorHandler ComNativeDescriptorHandler ComNativeDescriptorHandler ComNativeDescriptorHandler

获取或设置用于目标组件的组件对象模型 (COM) 类型信息的提供程序。Gets or sets the provider for the Component Object Model (COM) type information for the target component.

ComObjectType ComObjectType ComObjectType ComObjectType

获取由目标组件表示的组件对象模型 (COM) 对象的类型。Gets the type of the Component Object Model (COM) object represented by the target component.

InterfaceType InterfaceType InterfaceType InterfaceType

获取表示所有接口类型的类型说明提供程序的类型。Gets a type that represents a type description provider for all interface types.

方法

AddAttributes(Object, Attribute[]) AddAttributes(Object, Attribute[]) AddAttributes(Object, Attribute[]) AddAttributes(Object, Attribute[])

向目标组件实例添加类级别特性。Adds class-level attributes to the target component instance.

AddAttributes(Type, Attribute[]) AddAttributes(Type, Attribute[]) AddAttributes(Type, Attribute[]) AddAttributes(Type, Attribute[])

向目标组件类型添加类级别属性。Adds class-level attributes to the target component type.

AddEditorTable(Type, Hashtable) AddEditorTable(Type, Hashtable) AddEditorTable(Type, Hashtable) AddEditorTable(Type, Hashtable)

为给定的编辑器基类型添加编辑器表。Adds an editor table for the given editor base type.

AddProvider(TypeDescriptionProvider, Object) AddProvider(TypeDescriptionProvider, Object) AddProvider(TypeDescriptionProvider, Object) AddProvider(TypeDescriptionProvider, Object)

为某个组件的单个实例添加类型描述提供程序。Adds a type description provider for a single instance of a component.

AddProvider(TypeDescriptionProvider, Type) AddProvider(TypeDescriptionProvider, Type) AddProvider(TypeDescriptionProvider, Type) AddProvider(TypeDescriptionProvider, Type)

为组件类添加类型说明提供程序。Adds a type description provider for a component class.

AddProviderTransparent(TypeDescriptionProvider, Object) AddProviderTransparent(TypeDescriptionProvider, Object) AddProviderTransparent(TypeDescriptionProvider, Object) AddProviderTransparent(TypeDescriptionProvider, Object)

为某个组件的单个实例添加类型描述提供程序。Adds a type description provider for a single instance of a component.

AddProviderTransparent(TypeDescriptionProvider, Type) AddProviderTransparent(TypeDescriptionProvider, Type) AddProviderTransparent(TypeDescriptionProvider, Type) AddProviderTransparent(TypeDescriptionProvider, Type)

为组件类添加类型说明提供程序。Adds a type description provider for a component class.

CreateAssociation(Object, Object) CreateAssociation(Object, Object) CreateAssociation(Object, Object) CreateAssociation(Object, Object)

在两个对象之间创建主要和辅助关联。Creates a primary-secondary association between two objects.

CreateDesigner(IComponent, Type) CreateDesigner(IComponent, Type) CreateDesigner(IComponent, Type) 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[]) CreateEvent(Type, EventDescriptor, Attribute[]) CreateEvent(Type, EventDescriptor, Attribute[]) CreateEvent(Type, EventDescriptor, Attribute[])

当传递现有的 EventDescriptor 时,创建和现有事件描述符相同的新的事件描述符。Creates a new event descriptor that is identical to an existing event descriptor, when passed the existing EventDescriptor.

CreateEvent(Type, String, Type, Attribute[]) CreateEvent(Type, String, Type, Attribute[]) CreateEvent(Type, String, Type, Attribute[]) 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[]) CreateInstance(IServiceProvider, Type, Type[], Object[]) CreateInstance(IServiceProvider, Type, Type[], Object[]) CreateInstance(IServiceProvider, Type, Type[], Object[])

创建可替换为另一种数据类型的对象。Creates an object that can substitute for another data type.

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

使用指定的现有 PropertyDescriptor 和特性数组,从现有的属性描述符创建一个新的属性描述符。Creates a new property descriptor from an existing property descriptor, using the specified existing PropertyDescriptor and attribute array.

CreateProperty(Type, String, Type, Attribute[]) CreateProperty(Type, String, Type, Attribute[]) CreateProperty(Type, String, Type, Attribute[]) 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) Equals(Object) Equals(Object) Equals(Object)

确定指定的对象是否等于当前对象。Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetAssociation(Type, Object) GetAssociation(Type, Object) GetAssociation(Type, Object) GetAssociation(Type, Object)

返回以下类型的一个实例,该类型与指定的主要对象关联。Returns an instance of the type associated with the specified primary object.

GetAttributes(Object) GetAttributes(Object) GetAttributes(Object) GetAttributes(Object)

返回指定组件的特性的集合。Returns the collection of attributes for the specified component.

GetAttributes(Object, Boolean) GetAttributes(Object, Boolean) GetAttributes(Object, Boolean) 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) GetAttributes(Type) GetAttributes(Type) GetAttributes(Type)

返回指定类型组件的特性的集合。Returns a collection of attributes for the specified type of component.

GetClassName(Object) GetClassName(Object) GetClassName(Object) GetClassName(Object)

使用默认的类型说明符返回指定组件的类的名称。Returns the name of the class for the specified component using the default type descriptor.

GetClassName(Object, Boolean) GetClassName(Object, Boolean) GetClassName(Object, Boolean) GetClassName(Object, Boolean)

使用自定义类型说明符返回指定组件的类的名称。Returns the name of the class for the specified component using a custom type descriptor.

GetClassName(Type) GetClassName(Type) GetClassName(Type) GetClassName(Type)

返回指定类型的类的名称。Returns the name of the class for the specified type.

GetComponentName(Object) GetComponentName(Object) GetComponentName(Object) GetComponentName(Object)

使用默认的类型说明符返回指定组件的名称。Returns the name of the specified component using the default type descriptor.

GetComponentName(Object, Boolean) GetComponentName(Object, Boolean) GetComponentName(Object, Boolean) GetComponentName(Object, Boolean)

使用自定义类型说明符返回指定组件的名称。Returns the name of the specified component using a custom type descriptor.

GetConverter(Object) GetConverter(Object) GetConverter(Object) GetConverter(Object)

返回指定组件类型的类型转换器。Returns a type converter for the type of the specified component.

GetConverter(Object, Boolean) GetConverter(Object, Boolean) GetConverter(Object, Boolean) GetConverter(Object, Boolean)

使用自定义类型说明符返回指定组件类型的类型转换器。Returns a type converter for the type of the specified component with a custom type descriptor.

GetConverter(Type) GetConverter(Type) GetConverter(Type) GetConverter(Type)

返回指定类型的类型转换器。Returns a type converter for the specified type.

GetDefaultEvent(Object) GetDefaultEvent(Object) GetDefaultEvent(Object) GetDefaultEvent(Object)

返回指定组件的默认事件。Returns the default event for the specified component.

GetDefaultEvent(Object, Boolean) GetDefaultEvent(Object, Boolean) GetDefaultEvent(Object, Boolean) GetDefaultEvent(Object, Boolean)

使用自定义类型说明符返回组件的默认事件。Returns the default event for a component with a custom type descriptor.

GetDefaultEvent(Type) GetDefaultEvent(Type) GetDefaultEvent(Type) GetDefaultEvent(Type)

返回指定类型组件的默认事件。Returns the default event for the specified type of component.

GetDefaultProperty(Object) GetDefaultProperty(Object) GetDefaultProperty(Object) GetDefaultProperty(Object)

返回指定组件的默认属性。Returns the default property for the specified component.

GetDefaultProperty(Object, Boolean) GetDefaultProperty(Object, Boolean) GetDefaultProperty(Object, Boolean) GetDefaultProperty(Object, Boolean)

使用自定义类型说明符返回指定组件的默认属性。Returns the default property for the specified component with a custom type descriptor.

GetDefaultProperty(Type) GetDefaultProperty(Type) GetDefaultProperty(Type) GetDefaultProperty(Type)

返回指定类型组件的默认属性。Returns the default property for the specified type of component.

GetEditor(Object, Type) GetEditor(Object, Type) GetEditor(Object, Type) GetEditor(Object, Type)

用指定的基类型获取指定组件的编辑器。Gets an editor with the specified base type for the specified component.

GetEditor(Object, Type, Boolean) GetEditor(Object, Type, Boolean) GetEditor(Object, Type, Boolean) 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) GetEditor(Type, Type) GetEditor(Type, Type) GetEditor(Type, Type)

使用指定的基类型返回指定类型的编辑器。Returns an editor with the specified base type for the specified type.

GetEvents(Object) GetEvents(Object) GetEvents(Object) GetEvents(Object)

返回指定组件的事件的集合。Returns the collection of events for the specified component.

GetEvents(Object, Attribute[]) GetEvents(Object, Attribute[]) GetEvents(Object, Attribute[]) 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) GetEvents(Object, Attribute[], Boolean) GetEvents(Object, Attribute[], Boolean) 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) GetEvents(Object, Boolean) GetEvents(Object, Boolean) GetEvents(Object, Boolean)

使用自定义类型说明符返回指定组件的事件的集合。Returns the collection of events for a specified component with a custom type descriptor.

GetEvents(Type) GetEvents(Type) GetEvents(Type) GetEvents(Type)

返回指定类型组件的事件的集合。Returns the collection of events for a specified type of component.

GetEvents(Type, Attribute[]) GetEvents(Type, Attribute[]) GetEvents(Type, Attribute[]) GetEvents(Type, Attribute[])

通过将指定的特性数组用作筛选器,返回指定类型组件的事件的集合。Returns the collection of events for a specified type of component using a specified array of attributes as a filter.

GetFullComponentName(Object) GetFullComponentName(Object) GetFullComponentName(Object) GetFullComponentName(Object)

返回组件的完全限定名。Returns the fully qualified name of the component.

GetHashCode() GetHashCode() GetHashCode() GetHashCode()

作为默认哈希函数。Serves as the default hash function.

(Inherited from Object)
GetProperties(Object) GetProperties(Object) GetProperties(Object) GetProperties(Object)

返回指定组件的属性的集合。Returns the collection of properties for a specified component.

GetProperties(Object, Attribute[]) GetProperties(Object, Attribute[]) GetProperties(Object, Attribute[]) 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) GetProperties(Object, Attribute[], Boolean) GetProperties(Object, Attribute[], Boolean) 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) GetProperties(Object, Boolean) GetProperties(Object, Boolean) GetProperties(Object, Boolean)

使用默认类型说明符来返回指定组件的属性的集合。Returns the collection of properties for a specified component using the default type descriptor.

GetProperties(Type) GetProperties(Type) GetProperties(Type) GetProperties(Type)

返回指定类型组件的属性的集合。Returns the collection of properties for a specified type of component.

GetProperties(Type, Attribute[]) GetProperties(Type, Attribute[]) GetProperties(Type, Attribute[]) GetProperties(Type, Attribute[])

通过将指定的特性数组用作筛选器,返回指定类型组件的属性的集合。Returns the collection of properties for a specified type of component using a specified array of attributes as a filter.

GetProvider(Object) GetProvider(Object) GetProvider(Object) GetProvider(Object)

返回指定组件的类型说明提供程序。Returns the type description provider for the specified component.

GetProvider(Type) GetProvider(Type) GetProvider(Type) GetProvider(Type)

返回指定类型的类型说明提供程序。Returns the type description provider for the specified type.

GetReflectionType(Object) GetReflectionType(Object) GetReflectionType(Object) GetReflectionType(Object)

如果给定对象,则返回可用于执行反射的 TypeReturns a Type that can be used to perform reflection, given an object.

GetReflectionType(Type) GetReflectionType(Type) GetReflectionType(Type) GetReflectionType(Type)

如果给定类类型,则返回可用于执行反射的 TypeReturns a Type that can be used to perform reflection, given a class type.

GetType() GetType() GetType() GetType()

获取当前实例的 TypeGets the Type of the current instance.

(Inherited from Object)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(Inherited from Object)
Refresh(Assembly) Refresh(Assembly) Refresh(Assembly) Refresh(Assembly)

从缓存中清除指定程序集的属性和事件。Clears the properties and events for the specified assembly from the cache.

Refresh(Module) Refresh(Module) Refresh(Module) Refresh(Module)

从缓存中清除指定模块的属性和事件。Clears the properties and events for the specified module from the cache.

Refresh(Object) Refresh(Object) Refresh(Object) Refresh(Object)

从缓存中清除指定组件的属性和事件。Clears the properties and events for the specified component from the cache.

Refresh(Type) Refresh(Type) Refresh(Type) Refresh(Type)

从缓存中清除指定类型的组件的属性和事件。Clears the properties and events for the specified type of component from the cache.

RemoveAssociation(Object, Object) RemoveAssociation(Object, Object) RemoveAssociation(Object, Object) RemoveAssociation(Object, Object)

移除两个对象之间的关联。Removes an association between two objects.

RemoveAssociations(Object) RemoveAssociations(Object) RemoveAssociations(Object) RemoveAssociations(Object)

移除主要对象的所有关联。Removes all associations for a primary object.

RemoveProvider(TypeDescriptionProvider, Object) RemoveProvider(TypeDescriptionProvider, Object) RemoveProvider(TypeDescriptionProvider, Object) RemoveProvider(TypeDescriptionProvider, Object)

移除以前添加的且与指定对象关联的类型说明提供程序。Removes a previously added type description provider that is associated with the specified object.

RemoveProvider(TypeDescriptionProvider, Type) RemoveProvider(TypeDescriptionProvider, Type) RemoveProvider(TypeDescriptionProvider, Type) RemoveProvider(TypeDescriptionProvider, Type)

移除以前添加的且与指定类型关联的类型说明提供程序。Removes a previously added type description provider that is associated with the specified type.

RemoveProviderTransparent(TypeDescriptionProvider, Object) RemoveProviderTransparent(TypeDescriptionProvider, Object) RemoveProviderTransparent(TypeDescriptionProvider, Object) RemoveProviderTransparent(TypeDescriptionProvider, Object)

移除以前添加的且与指定对象关联的类型说明提供程序。Removes a previously added type description provider that is associated with the specified object.

RemoveProviderTransparent(TypeDescriptionProvider, Type) RemoveProviderTransparent(TypeDescriptionProvider, Type) RemoveProviderTransparent(TypeDescriptionProvider, Type) RemoveProviderTransparent(TypeDescriptionProvider, Type)

移除以前添加的且与指定类型关联的类型说明提供程序。Removes a previously added type description provider that is associated with the specified type.

SortDescriptorArray(IList) SortDescriptorArray(IList) SortDescriptorArray(IList) SortDescriptorArray(IList)

使用说明符的名称对说明符进行排序。Sorts descriptors using the name of the descriptor.

ToString() ToString() ToString() ToString()

返回表示当前对象的字符串。Returns a string that represents the current object.

(Inherited from Object)

事件

Refreshed Refreshed Refreshed Refreshed

清除组件的缓存时发生。Occurs when the cache for a component is cleared.

适用于

另请参阅