/// <summary> /// </summary> /// <param name="owner">form owner for the UI Dialog</param> /// <param name="component">the class instance to edit</param> /// <param name="propertyName">property name to edit (must have the Editor attribute)</param> /// <remarks></remarks> public static void ShowEditor(IWin32Window owner, object component, string propertyName) { PropertyDescriptor property = TypeDescriptor.GetProperties(RuntimeHelpers.GetObjectValue(component))[propertyName]; if (property == null) { throw new ArgumentException(nameof(propertyName)); } UITypeEditor editor = (UITypeEditor)property.GetEditor(typeof(UITypeEditor)); if (editor == null) { throw new NotImplementedException("Unsupported UIEditor Type"); } if (!(editor.GetType().IsSubclassOf(typeof(EnhancedCollectionEditor)) | editor.GetType().IsSubclassOf(typeof(CollectionEditor)))) { throw new NotImplementedException("Unsupported UIEditor Type"); } RunTimeUIEdTools.RunTimeTypeEdit runTimeTypeEdit = new RunTimeUIEdTools.RunTimeTypeEdit(owner, RuntimeHelpers.GetObjectValue(component), property); object objectValue1 = RuntimeHelpers.GetObjectValue(property.GetValue(RuntimeHelpers.GetObjectValue(component))); object objectValue2 = RuntimeHelpers.GetObjectValue(editor.EditValue((ITypeDescriptorContext)runTimeTypeEdit, (IServiceProvider)runTimeTypeEdit, RuntimeHelpers.GetObjectValue(objectValue1))); if (property.IsReadOnly) { return; } property.SetValue(RuntimeHelpers.GetObjectValue(component), RuntimeHelpers.GetObjectValue(objectValue2)); }