ICustomTypeDescriptor,TypeDescriptionProvider,类型转换器和UITypeEditor的 [英] ICustomTypeDescriptor, TypeDescriptionProvider, TypeConverter, and UITypeEditor

查看:979
本文介绍了ICustomTypeDescriptor,TypeDescriptionProvider,类型转换器和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

  • 可以为每个类型的应用,以及每个实例,从而可以应用到列表,而无需执行 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 that ExpandableObjectConverter simply delegates to TypeDescriptor.GetProperties, but this is not always the case
  • also responsible for re-creating immutable objects (such as structs) with changes

UITypeEditor的


  • 还负责的PropertyGrid

  • 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 with TypeDescriptionProvider
  • ITypedList - broadly the twin of ICustomTypeDescriptor, but for lists; can be avoided by use of TypeDescriptionProvider and a non-object indexer on any IList, i.e. public T this[int index] {get;}
  • IListSource - provides indirection between a data-source and the data; for example, a DataTable implements IListSource, returning DefaultView when requested

这篇关于ICustomTypeDescriptor,TypeDescriptionProvider,类型转换器和UITypeEditor的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆