且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

ICustomTypeDescriptor,TypeDescriptionProvider,类型转换器和UITypeEditor的

更新时间:2023-01-01 10:01:32

调整菜谱:


  • 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 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 $ 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 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