反射类型和类型描述符
问题描述:
最近我一直在使用反射在我的项目中工作,并且我有当前的问题。反射类型和类型描述符
在Type.GetProperties(Flags)
中,我们可以过滤使用'Flags'的属性;在TypeDescriptor.GetProperties()
,我们没有。
在type.GetProperties
我可以过滤得到只有属性不继承。 是否有可能对TypeDescriptor.GetProperties()
(只有属性没有继承)做同样的事情?
谢谢
答
不,你不能。
TypeDescriptor.GetProperties()
用于获取PropertyDescriptor
实例,并可能使用特定的Attribute
进行过滤。
Type.GetProperties()
用于获得PropertyInfo
实例,可能使用特定的BindingFlags
进行过滤。
另请参阅http://stackoverflow.com/questions/1402239/typedescriptor-getproperties-vs-type-getproperties – nawfal 2013-04-25 05:21:50