void AppendProperty(string parentName, List <TableRow> rowList, PropertyDescriptor prop, object instance) { string fullName = parentName + (!string.IsNullOrEmpty(parentName) ? "." : "") + prop.Name; TableRow row = new TableRow() { IsCategory = false, Property = prop, Label = prop.DisplayName, FullName = fullName, Instace = instance, IsDefaultValue = prop.Equals(null), }; rowList.Add(row); TypeConverter tc = prop.Converter; if (typeof(ExpandableObjectConverter).IsAssignableFrom(tc.GetType())) { object cob = prop.GetValue(instance); row.ChildRows = new List <TableRow> (); foreach (PropertyDescriptor cprop in tc.GetProperties(cob)) //TypeDescriptor.GetConverter(cob.GetType()).GetProperties(cob)) { AppendProperty(fullName, row.ChildRows, cprop, cob); } } }
public bool Equals(DescriptorPropertyInfo other) { if (other is null) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return(PropertyDescriptor.Equals(other.PropertyDescriptor)); }
/// <summary> /// Tests if two instances are equal. /// </summary> /// <param name="obj">Instance to compare with.</param> /// <returns>true if instances are equal, and false otherwise.</returns> public override bool Equals(object obj) { if (this == obj) { return(true); } UndoRedoProperty that = obj as UndoRedoProperty; if (that == null) { return(false); } return(parent.Equals(that.parent)); }
/// <summary> /// Creates sort list from a property whose value is sorted by and a direction</summary> /// <param name="prop">Property whose value is sorted by</param> /// <param name="direction">Sort direction</param> protected override void ApplySortCore(PropertyDescriptor prop, ListSortDirection direction) { if (prop.Equals(_lastProperty)) { direction = _lastDirection == ListSortDirection.Ascending ? ListSortDirection.Descending : ListSortDirection.Ascending; _lastDirection = direction; } else { _lastProperty = prop; _lastDirection = direction; } //base.ApplySortCore(prop, direction); ListSortDescription[] arr = { new ListSortDescription(prop, direction) }; ApplySort(new ListSortDescriptionCollection(arr)); }
/// <summary> /// Crée la collection des descripteurs de propriétés. /// </summary> /// <param name="properties">PropertyDescriptors.</param> /// <param name="defaultProperty">Propriété par défaut.</param> /// <param name="beanType">Type du bean.</param> /// <param name="metadataProperties">Métadonnées.</param> /// <returns>Collection.</returns> private static BeanPropertyDescriptorCollection CreateCollection(PropertyDescriptorCollection properties, PropertyDescriptor defaultProperty, Type beanType, PropertyDescriptorCollection metadataProperties) { BeanPropertyDescriptorCollection coll = new BeanPropertyDescriptorCollection(beanType); for (int i = 0; i < properties.Count; i++) { PropertyDescriptor property = properties[i]; KeyAttribute keyAttr = (KeyAttribute)property.Attributes[typeof(KeyAttribute)]; DisplayAttribute displayAttr = (DisplayAttribute)property.Attributes[typeof(DisplayAttribute)]; ReferencedTypeAttribute attr = (ReferencedTypeAttribute)property.Attributes[typeof(ReferencedTypeAttribute)]; ColumnAttribute colAttr = (ColumnAttribute)property.Attributes[typeof(ColumnAttribute)]; DomainAttribute domainAttr = (DomainAttribute)property.Attributes[typeof(DomainAttribute)]; RequiredAttribute requiredAttr = (RequiredAttribute)property.Attributes[typeof(RequiredAttribute)]; TranslatableAttribute translatableAttr = (TranslatableAttribute)property.Attributes[typeof(TranslatableAttribute)]; Type[] genericArgumentArray = beanType.GetGenericArguments(); string display = null; if (displayAttr != null) { if (displayAttr.ResourceType != null && displayAttr.Name != null) { Dictionary <string, PropertyInfo> resourceProperties; if (!_resourceTypeMap.TryGetValue(displayAttr.ResourceType, out resourceProperties)) { resourceProperties = new Dictionary <string, PropertyInfo>(); _resourceTypeMap[displayAttr.ResourceType] = resourceProperties; foreach (PropertyInfo p in displayAttr.ResourceType.GetProperties(BindingFlags.Public | BindingFlags.Static)) { resourceProperties.Add(p.Name, p); } } display = resourceProperties[displayAttr.Name].GetValue(null, null).ToString(); } else { display = displayAttr.Name; } } string memberName = (colAttr == null) ? null : colAttr.Name; bool isPrimaryKey = keyAttr != null; bool isRequired = requiredAttr != null; bool isTranslatable = translatableAttr != null; string domainName = (domainAttr == null) ? null : domainAttr.Name; bool isDefault = property.Equals(defaultProperty) || (DefaultPropertyDefaultName.Equals(property.Name) && defaultProperty == null); Type referenceType = attr == null ? null : attr.ReferenceType; //// Type dtoType = genericArgumentArray.Length > 0 ? genericArgumentArray[0] : beanType; bool isBrowsable = property.IsBrowsable; bool isReadonly = property.IsReadOnly; // Traitement des métadonnées. if (metadataProperties != null) { PropertyDescriptor metadata = metadataProperties[property.Name]; if (metadata != null) { if (!metadata.IsBrowsable) { isBrowsable = false; } if (metadata.Attributes[typeof(RequiredAttribute)] != null) { isRequired = true; } if (metadata.Attributes[typeof(TranslatableAttribute)] != null) { isTranslatable = true; } ReadOnlyAttribute readonlyAttr = (ReadOnlyAttribute)metadata.Attributes[typeof(ReadOnlyAttribute)]; if (readonlyAttr != null && readonlyAttr.IsReadOnly) { isReadonly = true; } } } BeanPropertyDescriptor description = new BeanPropertyDescriptor( property.Name, memberName, property.PropertyType, display, domainName, isPrimaryKey, isDefault, isRequired, referenceType, isReadonly, isBrowsable, isTranslatable); if (domainName != null) { DomainManager.Instance.GetDomain(description); } coll.Add(description); } return(coll); }
// this returns an array list of the propertydescriptor arrays, one for each // component // private static ArrayList GetCommonProperties(object[] objs, bool presort, PropertyTab tab, GridEntry parentEntry) { PropertyDescriptorCollection[] propCollections = new PropertyDescriptorCollection[objs.Length]; Attribute[] attrs = new Attribute[parentEntry.BrowsableAttributes.Count]; parentEntry.BrowsableAttributes.CopyTo(attrs, 0); for (int i = 0; i < objs.Length; i++) { PropertyDescriptorCollection pdc = tab.GetProperties(parentEntry, objs[i], attrs); if (presort) { pdc = pdc.Sort(PropertyComparer); } propCollections[i] = pdc; } ArrayList mergedList = new ArrayList(); PropertyDescriptor[] matchArray = new PropertyDescriptor[objs.Length]; // // Merge the property descriptors // int[] posArray = new int[propCollections.Length]; for (int i = 0; i < propCollections[0].Count; i++) { PropertyDescriptor pivotDesc = propCollections[0][i]; bool match = pivotDesc.Attributes[typeof(MergablePropertyAttribute)].IsDefaultAttribute(); for (int j = 1; match && j < propCollections.Length; j++) { if (posArray[j] >= propCollections[j].Count) { match = false; break; } // check to see if we're on a match // PropertyDescriptor jProp = propCollections[j][posArray[j]]; if (pivotDesc.Equals(jProp)) { posArray[j] += 1; if (!jProp.Attributes[typeof(MergablePropertyAttribute)].IsDefaultAttribute()) { match = false; break; } matchArray[j] = jProp; continue; } int jPos = posArray[j]; jProp = propCollections[j][jPos]; match = false; // if we aren't on a match, check all the items until we're past // where the matching item would be while (PropertyComparer.Compare(jProp, pivotDesc) <= 0) { // got a match! if (pivotDesc.Equals(jProp)) { if (!jProp.Attributes[typeof(MergablePropertyAttribute)].IsDefaultAttribute()) { match = false; jPos++; } else { match = true; matchArray[j] = jProp; posArray[j] = jPos + 1; } break; } // try again jPos++; if (jPos < propCollections[j].Count) { jProp = propCollections[j][jPos]; } else { break; } } // if we got here, there is no match, quit for this guy if (!match) { posArray[j] = jPos; break; } } // do we have a match? if (match) { matchArray[0] = pivotDesc; mergedList.Add(matchArray.Clone()); } } return(mergedList); }
public override bool Equals(object o) { return(prop.Equals(o)); }
public override bool Equals(object objectValue) { PropertyDesignBuffer buffer = objectValue as PropertyDesignBuffer; if ((buffer != null) && Object.ReferenceEquals(_instance, buffer.Instance) && _descriptor.Equals(buffer.Descriptor)) { return(true); } else { return(base.Equals(objectValue)); } }
public override bool Equals(object obj) { return(_basePropertyDescriptor.Equals(obj)); }
public override bool Equals(object obj) { return(root.Equals(obj)); }
// ReSharper disable once MemberCanBePrivate.Local protected bool Equals(Reflected other) { return(base.Equals(other) && _propertyDescriptor.Equals(other._propertyDescriptor)); }
private static ArrayList GetCommonProperties(object[] objects, bool presort, PropertyTab tab, GridEntry parentEntry) { var propertyCollections = new PropertyDescriptorCollection[objects.Length]; var attributes = new Attribute[parentEntry.BrowsableAttributes.Count]; parentEntry.BrowsableAttributes.CopyTo(attributes, 0); for (int i = 0; i < objects.Length; i++) { var properties = tab.GetProperties(parentEntry, objects[i], attributes); if (presort) { properties = properties.Sort(s_propertyComparer); } propertyCollections[i] = properties; } ArrayList mergedList = new(); var matchArray = new PropertyDescriptor[objects.Length]; // // Merge the property descriptors // int[] positions = new int[propertyCollections.Length]; for (int i = 0; i < propertyCollections[0].Count; i++) { PropertyDescriptor pivotProperty = propertyCollections[0][i]; bool match = pivotProperty.Attributes[typeof(MergablePropertyAttribute)].IsDefaultAttribute(); for (int j = 1; match && j < propertyCollections.Length; j++) { if (positions[j] >= propertyCollections[j].Count) { match = false; break; } // Check to see if we're on a match. PropertyDescriptor property = propertyCollections[j][positions[j]]; if (pivotProperty.Equals(property)) { positions[j] += 1; if (!property.Attributes[typeof(MergablePropertyAttribute)].IsDefaultAttribute()) { match = false; break; } matchArray[j] = property; continue; } int position = positions[j]; property = propertyCollections[j][position]; match = false; // If we aren't on a match, check all the items until we're past where the matching item would be. while (s_propertyComparer.Compare(property, pivotProperty) <= 0) { // Got a match! if (pivotProperty.Equals(property)) { if (!property.Attributes[typeof(MergablePropertyAttribute)].IsDefaultAttribute()) { match = false; position++; } else { match = true; matchArray[j] = property; positions[j] = position + 1; } break; } // Try again. position++; if (position < propertyCollections[j].Count) { property = propertyCollections[j][position]; } else { break; } } // If we got here, there is no match, quit for this one. if (!match) { positions[j] = position; break; } } // Do we have a match? if (match) { matchArray[0] = pivotProperty; mergedList.Add(matchArray.Clone()); } } return(mergedList); }
private static ArrayList GetCommonProperties(object[] objs, bool presort, PropertyTab tab, GridEntry parentEntry) { PropertyDescriptorCollection[] descriptorsArray = new PropertyDescriptorCollection[objs.Length]; Attribute[] array = new Attribute[parentEntry.BrowsableAttributes.Count]; parentEntry.BrowsableAttributes.CopyTo(array, 0); for (int i = 0; i < objs.Length; i++) { PropertyDescriptorCollection descriptors = tab.GetProperties(parentEntry, objs[i], array); if (presort) { descriptors = descriptors.Sort(MultiSelectRootGridEntry.PropertyComparer); } descriptorsArray[i] = descriptors; } ArrayList list = new ArrayList(); PropertyDescriptor[] descriptorArray = new PropertyDescriptor[objs.Length]; int[] numArray = new int[descriptorsArray.Length]; for (int j = 0; j < descriptorsArray[0].Count; j++) { PropertyDescriptor descriptor = descriptorsArray[0][j]; bool flag = descriptor.Attributes[typeof(MergablePropertyAttribute)].IsDefaultAttribute(); for (int k = 1; flag && (k < descriptorsArray.Length); k++) { if (numArray[k] >= descriptorsArray[k].Count) { flag = false; break; } PropertyDescriptor descriptor2 = descriptorsArray[k][numArray[k]]; if (descriptor.Equals(descriptor2)) { numArray[k]++; if (!descriptor2.Attributes[typeof(MergablePropertyAttribute)].IsDefaultAttribute()) { flag = false; break; } descriptorArray[k] = descriptor2; continue; } int num4 = numArray[k]; descriptor2 = descriptorsArray[k][num4]; flag = false; while (MultiSelectRootGridEntry.PropertyComparer.Compare(descriptor2, descriptor) <= 0) { if (descriptor.Equals(descriptor2)) { if (!descriptor2.Attributes[typeof(MergablePropertyAttribute)].IsDefaultAttribute()) { flag = false; num4++; } else { flag = true; descriptorArray[k] = descriptor2; numArray[k] = num4 + 1; } break; } num4++; if (num4 >= descriptorsArray[k].Count) { break; } descriptor2 = descriptorsArray[k][num4]; } if (!flag) { numArray[k] = num4; break; } } if (flag) { descriptorArray[0] = descriptor; list.Add(descriptorArray.Clone()); } } return(list); }