2011-03-12 92 views
10

最近我一直在使用反射在我的項目中工作,並且我有當前的問題。反射類型和類型描述符

Type.GetProperties(Flags)中,我們可以過濾使用'Flags'的屬性;在TypeDescriptor.GetProperties(),我們沒有。

type.GetProperties我可以過濾得到只有屬性不繼承。 是否有可能對TypeDescriptor.GetProperties()(只有屬性沒有繼承)做同樣的事情?

謝謝

+0

另請參閱http://stackoverflow.com/questions/1402239/typedescriptor-getproperties-vs-type-getproperties – nawfal 2013-04-25 05:21:50

回答

5

不,你不能。

TypeDescriptor.GetProperties()用於獲取PropertyDescriptor實例,並可能使用特定的Attribute進行過濾。

Type.GetProperties()用於獲得PropertyInfo實例,可能使用特定的BindingFlags進行過濾。