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); }
private PropertyDescriptorCollection InitializePropertyDescriptors() { if (this._values == null) { return((PropertyDescriptorCollection)null); } if (this._propertyDescriptors == null && 0 < this._values.Length) { this._propertyDescriptors = MaterializedDataRecord.CreatePropertyDescriptorCollection(this.DataRecordInfo.RecordType.EdmType as StructuralType, typeof(MaterializedDataRecord), true); } return(this._propertyDescriptors); }
PropertyDescriptorCollection 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. var propertyDescriptor = listAccessors[listAccessors.Length - 1]; var 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); }
PropertyDescriptorCollection ITypedList.GetItemProperties( PropertyDescriptor[] listAccessors) { PropertyDescriptorCollection descriptorCollection; if (listAccessors == null || listAccessors.Length == 0) { descriptorCollection = this._propertyDescriptorsCache; } else { PropertyDescriptor listAccessor = listAccessors[listAccessors.Length - 1]; FieldDescriptor fieldDescriptor = listAccessor as FieldDescriptor; descriptorCollection = fieldDescriptor == null || fieldDescriptor.EdmProperty == null || fieldDescriptor.EdmProperty.TypeUsage.EdmType.BuiltInTypeKind != BuiltInTypeKind.RowType ? TypeDescriptor.GetProperties(DataRecordObjectView.GetListItemType(listAccessor.PropertyType)) : MaterializedDataRecord.CreatePropertyDescriptorCollection((StructuralType) fieldDescriptor.EdmProperty.TypeUsage.EdmType, typeof (IDataRecord), true); } return descriptorCollection; }