问题描述
之间存在什么ü可以与他们做一个独特的重叠。是ComponentModel反思的东西刚上的System.Reflection之上一点点友好层
There is a distinct overlap between what u can do with both of them. Is the ComponentModel reflection stuff just a little friendlier layer on top of System.Reflection?
推荐答案
没有? - 还有更多。 ComponentModel允许你做了几个DLR型的东西,比如运行时性能。这是一个DataView如何暴露列的网格 - 他们不是反射特性 - 他们是运行时属性。这里的关键词是 ICustomTypeDescriptor
和 TypeDescriptionProvider
。
No - there is more. ComponentModel allows you to do a few DLR-type things, such as runtime-properties. This is how a DataView exposes columns to a grid - they aren't reflection properties - they are runtime properties. The keywords here are ICustomTypeDescriptor
and TypeDescriptionProvider
.
这模型还允许抽象和间接。例如,如果你是做了很多的属性反思,考虑 - 这是一个实用程序我写道,使用自定义的的PropertyDescriptor
实施交换反射模型预编译的模型中,巨大的性能提升。
This model also allows abstraction and indirection. For example, if you are doing a lot of reflection on properties, consider HyperDescriptor - this is a utility I wrote that uses a custom PropertyDescriptor
implementation to swap the reflection model for a pre-compiled model, for huge performance boosts.
在使用方面,也有一些其他方面的差异; ComponentModel仅支持构件(不像反射,其中多个相似属性是允许的话)的任何属性的一个实例。它是以数据为中心 - 因此属性的存在,因为这样做的事件(主要用于变更通知) - 但有没有字段也没有方法
In terms of usage, there are some other differences; ComponentModel only supports a single instance of any attribute on a member (unlike reflection, where multiple alike attributes are allows). And it is data-centric - so properties exist, as do events (primarily intended for change notification) - but there are no fields nor methods.
它也有很好的支持对于国际化 - 因为显示名称等可以实时进行定制
It also has good support for i18n - since the DisplayName etc can be customized on the fly.
不过,ComponentModel不(直接)的东西像LINQ(特别MemberExpression)兼容 - 因为这要绑定到反射数据。
However, ComponentModel is not (directly) compatible with things like LINQ (MemberExpression in particular) - since this wants to bind to reflection data.
最后,ComponentModel高度由之类的PropertyGrid IDE中使用(这东西像工具提示的额外的属性是如何工作的) ,但同样几乎所有的UI通过数据绑定ComponentModel发生(因为这允许绑定到数据表支持,类,和其他任何你能想到的)。
Finally, ComponentModel is highly used in the IDE by things like PropertyGrid (this is how things like the extra properties for tool-tips work), but equally almost all UI data binding happens via ComponentModel (since this allows the binding to support DataTable, classes, and anything else you can think of).
这篇关于ComponentModel反射(例如PropertyDescriptor的)和标准反射(如的PropertyInfo)之间的区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!