/// <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)); }