ICustomTypeDescriptor,TypeDescriptionProvider,类型转换器和UITypeEditor的 [英] ICustomTypeDescriptor, TypeDescriptionProvider, TypeConverter, and UITypeEditor
问题描述
我想了解你如何使用ICustomTypeDescriptor,TypeDescriptionProvider,类型转换器和UITypeEditor的一个整体的认识改变如何PropertyGrid中显示和接口的对象。
I'm trying to get an overall understanding of how you use ICustomTypeDescriptor, TypeDescriptionProvider, TypeConverter, and UITypeEditor to change how a PropertyGrid displays and interfaces with an object.
谁能告诉我,如果这是正确的,或者如果我错过任何重要的概念或点?我真的只是想了解为何以及何时应该使用每个类。
Can someone tell me if this is right, or if I missed any major concepts or points? I'm really just trying to understand why and when you would use each class.
ICustomTypeDescriptor
- 在一个类实现此接口完全以覆盖类的本地属性和与ICustomTypeDescriptor.GetProperties返回的PropertyDescriptor替换它们()
TypeDescriptionProvider
- 用于对现有属性来扩展一类
- 系统TypeDescriptionProvider通过TypeDescriptionProvider属性
- 的TypeDescriptionProvider的GetTypeDescriptor()方法返回一个ICustomTypeDescriptor为<强>的附的以该类型的现有属性
- 系统的PropertyGrid将显示通过反射发现的类的两个属性,属性增加。通过TypeDescriptionProvider
追加到一个类
- Used to extend on the existing properties of a class
- A TypeDescriptionProvider is appended to a class through a TypeDescriptionProvider attribute
- The GetTypeDescriptor() method of the TypeDescriptionProvider returns an ICustomTypeDescriptor to be appended to the existing properties of the type.
- A PropertyGrid will show both the properties of the class found through Reflection, and the properties added to the class through the TypeDescriptionProvider
的TypeConverter
- 类型
- 之间的转换在使用PropetyGrid方面用于复杂类型和原始类型可以显示/在属性网格编辑之间进行转换。
- 也可使用的TypeConverter的GetStandard值的方法,以显示在PropertyGrid中可能值的列表
UITypeEditor的
- 定义操作复杂类型的属性的自定义编辑器。
- 有关通过属性的属性。
因此ICustomTypeDescriptor的TypeDescription提供用于添加/更改/替换对象的全部属性。 ,类型转换器和UITypeEditor的应用到各个属性和控制这些特定的属性如何与接口
So ICustomTypeDescriptor an TypeDescription provider are used to add/change/replace entire properties of objects. TypeConverter and UITypeEditor are applied to individual properties and control how those specific properties are interfaced with.
推荐答案
调整菜谱:
-
TypeDescriptionProvider
- 还是替换的元数据(不扩展)
- 也可以为
TypeDescriptor.AddProvider $ C $加C>
- 可以为每个类型的应用,以及每个实例,从而可以应用到列表,而无需执行
ITypedList
- still replaces metadata (not extends)
- can also be added be
TypeDescriptor.AddProvider
- can be applied per-type as well as per-instance, making it possible to apply to lists without having to implement
ITypedList
的TypeConverter
- 为
的PropertyGrid
,这也是用来获取元数据的机制;注意,ExpandableObjectConverter
只是委托给TypeDescriptor.GetProperties
,但这并非总是如此 - 还负责重新创建不可变对象(如结构)有改动
- for
PropertyGrid
, this is also the mechanism used to obtain metadata; note thatExpandableObjectConverter
simply delegates toTypeDescriptor.GetProperties
, but this is not always the case - also responsible for re-creating immutable objects (such as structs) with changes
UITypeEditor的
- 还负责
的PropertyGrid $ C画预览框中$ C>
- also responsible for painting the preview box in
PropertyGrid
其他:
-
IExtenderProvider
- 追加的性能;这可能是你感到困惑什么用TypeDescriptionProvider
-
ITypedList
- 广泛ICustomTypeDescriptor
的双胞胎,但对于名单;可以通过使用TypeDescriptionProvider
,并在任何一个非对象索引来避免的IList
,即公共ŧ这个[INT指数] {获得;}
-
IListSource
- 一个数据 - 之间提供间接源和数据;例如,数据表
工具IListSource
,返回默认视图
时要求
IExtenderProvider
- appends properties; this may be what you were getting confused withTypeDescriptionProvider
ITypedList
- broadly the twin ofICustomTypeDescriptor
, but for lists; can be avoided by use ofTypeDescriptionProvider
and a non-object indexer on anyIList
, i.e.public T this[int index] {get;}
IListSource
- provides indirection between a data-source and the data; for example, aDataTable
implementsIListSource
, returningDefaultView
when requested
这篇关于ICustomTypeDescriptor,TypeDescriptionProvider,类型转换器和UITypeEditor的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!