TypeDescriptor. GetProperties () по сравнению с типом. GetProperties ()

Вы могли создать NHibernate IUserType и определить его с помощью CustomTypeIs<T>() на карте свойства.

32
задан John K 13 March 2010 в 20:10
поделиться

2 ответа

obj.GetType().GetProperties() does not return a PropertyDescriptorCollection, it returns a System.Reflection.PropertyInfo[]. The PropertyInfo class does, as you suggest, represent only actual properties created on the object. A PropertyDescriptor is either a custom concrete child of the PropertyDescriptor class (implemented by the type defining the custom descriptor), or is an instance of the sealed internal class ReflectPropertyDescriptor that uses the PropertyInfo class to provide dynamic invocation of the property.

So for a class that does not define a custom descriptor, you will functionally get the same objects back, though the PropertyDescriptor is abstracting away the PropertyInfo.

18
ответ дан 27 November 2019 в 21:08
поделиться

Класс TypeDescriptor используется в дизайнерах, чтобы они могли взаимодействовать со средой времени разработки. В частности, разработчики могут переопределять и расширять различные функции TypeDescriptor , но не Type .

Хорошим примером является работа с элементами управления с привязкой к данным. Свойство DataSource относится к типу System.Object , однако во время разработки это свойство заменяется новым свойством с более богатым пользовательским интерфейсом времени разработки.

9
ответ дан 27 November 2019 в 21:08
поделиться
Другие вопросы по тегам:

Похожие вопросы: