Пример #1
0
        PropertyDescriptorCollection System.ComponentModel.ITypedList.GetItemProperties(PropertyDescriptor[] listAccessors)
        {
            PropertyDescriptorCollection propertyDescriptors;

            if (listAccessors == null || listAccessors.Length == 0)
            {
                // Caller is requesting property descriptors for the root element type.
                propertyDescriptors = _propertyDescriptorsCache;
            }
            else
            {
                // Use the last PropertyDescriptor in the array to build the collection of returned property descriptors.
                PropertyDescriptor propertyDescriptor = listAccessors[listAccessors.Length - 1];
                FieldDescriptor    fieldDescriptor    = propertyDescriptor as FieldDescriptor;

                // If the property descriptor describes a data record with the EDM type of RowType,
                // construct the collection of property descriptors from the property's EDM metadata.
                // Otherwise use the CLR type of the property.
                if (fieldDescriptor != null && fieldDescriptor.EdmProperty != null && fieldDescriptor.EdmProperty.TypeUsage.EdmType.BuiltInTypeKind == BuiltInTypeKind.RowType)
                {
                    // Retrieve property descriptors from EDM metadata.
                    propertyDescriptors = MaterializedDataRecord.CreatePropertyDescriptorCollection((RowType)fieldDescriptor.EdmProperty.TypeUsage.EdmType, typeof(IDataRecord), true);
                }
                else
                {
                    // Use the CLR type.
                    propertyDescriptors = TypeDescriptor.GetProperties(GetListItemType(propertyDescriptor.PropertyType));
                }
            }

            return(propertyDescriptors);
        }
Пример #2
0
        internal DataRecordObjectView(IObjectViewData <DbDataRecord> viewData, object eventDataSource, RowType rowType, Type propertyComponentType)
            : base(viewData, eventDataSource)
        {
            if (!typeof(IDataRecord).IsAssignableFrom(propertyComponentType))
            {
                propertyComponentType = typeof(IDataRecord);
            }

            _rowType = rowType;
            _propertyDescriptorsCache = MaterializedDataRecord.CreatePropertyDescriptorCollection(_rowType, propertyComponentType, true);
        }