private IEnumerable <PropertyItem> CollectProperties(object[] components) { if (components == null || components.Length == 0) { throw new ArgumentNullException("components"); } // This is an obsolete code left for performance improvements demo. Will be removed in the future versions. /* * var descriptors = component.Length == 1 * ? TypeDescriptor.GetProperties(component[0], DefaultPropertiesFilter).OfType<PropertyDescriptor>() * : ObjectServices.GetMergedProperties(component); */ // TODO: PropertyItem is to be wired with PropertyData rather than pure PropertyDescriptor in the next version! var descriptors = (components.Length == 1) ? MetadataRepository.GetProperties(components[0]).Select(prop => prop.Descriptor) : ObjectServices.GetMergedProperties(components); IList <PropertyItem> propertyCollection = new List <PropertyItem>(); foreach (var propertyDescriptor in descriptors) // This is an obsolete code left for performance improvements demo. Will be removed in the future versions. //CollectProperties(component, propertyDescriptor, propertyCollection); { var item = CreatePropertyItem(propertyDescriptor); if (item != null) { propertyCollection.Add(item); } } return(propertyCollection); }
/// <summary> /// Gets the editor. /// </summary> /// <param name="propertyItem">The property item.</param> /// <returns>Editor for Property</returns> public Editor GetEditor(PropertyItem propertyItem) { if (propertyItem == null) { throw new ArgumentNullException("propertyItem"); } Editor editor; if (propertyItem.Attributes != null) { editor = GetPropertyEditorByAttributes(propertyItem.Attributes); if (editor != null) { return(editor); } } if (propertyItem.Component != null && !string.IsNullOrEmpty(propertyItem.Name)) { object declaringObject = ObjectServices.GetUnwrappedObject(propertyItem.Owner.SelectedObject); editor = this.FindPropertyEditor(declaringObject.GetType(), propertyItem.Name); if (editor != null) { return(editor); } } if (propertyItem.PropertyValue.HasSubProperties) { return(new TypeEditor(propertyItem.PropertyType, EditorKeys.ComplexPropertyEditorKey)); } bool hasType = propertyItem.PropertyType != null; if (hasType) { editor = this.FindTypeEditor(propertyItem.PropertyType); if (editor != null) { { return(editor); } } if (hasType) { foreach (var cachedEditor in Cache) { if (cachedEditor.Key.IsAssignableFrom(propertyItem.PropertyType)) { return(cachedEditor.Value); } } return(new TypeEditor(propertyItem.PropertyType, EditorKeys.DefaultEditorKey)); } } return(null); }
/// <summary> /// Gets the editor. /// </summary> /// <param name="categoryItem">The category item.</param> /// <returns>Editor for Category</returns> public Editor GetEditor(CategoryItem categoryItem) { if (categoryItem == null) { throw new ArgumentNullException("categoryItem"); } if (categoryItem.Owner == null) { return(null); } object declaringObject = ObjectServices.GetUnwrappedObject(categoryItem.Owner.SelectedObject); if (declaringObject == null) { return(null); } Type declaringType = declaringObject.GetType(); Editor editor = FindCategoryEditor(declaringType, categoryItem.Name); if (editor != null) { return(editor); } editor = GetCategoryEditorByAttributes(declaringType, categoryItem.Name); if (editor != null) { return(editor); } return(new CategoryEditor(declaringType, categoryItem.Name, EditorKeys.DefaultCategoryEditorKey)); }
/// <summary> /// Gets the serialization culture. /// </summary> /// <returns>Culture to serialize value.</returns> protected virtual CultureInfo GetSerializationCulture() { return(ObjectServices.GetSerializationCulture(_property.PropertyType)); }