From ef5a1fe2b3ab08ecd06ec6fd86e871261c53d0b2 Mon Sep 17 00:00:00 2001 From: Curtis Wensley Date: Sat, 1 Jun 2024 15:50:13 -0700 Subject: [PATCH] No need to use reflection anymore to get converter properties/supported --- .../ThemedControls/ThemedPropertyGridHandler.cs | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/src/Eto/Forms/ThemedControls/ThemedPropertyGridHandler.cs b/src/Eto/Forms/ThemedControls/ThemedPropertyGridHandler.cs index e5b7da8b3a..a7fa0405f3 100644 --- a/src/Eto/Forms/ThemedControls/ThemedPropertyGridHandler.cs +++ b/src/Eto/Forms/ThemedControls/ThemedPropertyGridHandler.cs @@ -499,15 +499,7 @@ string GetDataTypeText() return null; } - static MethodInfo s_GetPropertiesSupportedMethod = typeof(sc.TypeConverter).GetRuntimeMethod("GetPropertiesSupported", new Type[0]); - static MethodInfo s_GetPropertiesMethod = typeof(sc.TypeConverter).GetRuntimeMethod("GetProperties", new Type[] { typeof(object) }); - - public bool GetIsExpandable() - { - if (s_GetPropertiesSupportedMethod == null || Converter == null) - return false; - return (bool)s_GetPropertiesSupportedMethod.Invoke(Converter, null); - } + public bool GetIsExpandable() => Converter?.GetPropertiesSupported() == true; public bool CanSetCollection { @@ -654,12 +646,12 @@ public void SetCollection(IEnumerable newCollection) void EnsureChildren() { - if (_childrenInitialized || s_GetPropertiesMethod == null || Converter == null || !HasValue || !PropertyDescriptorDescriptor.IsSupported) + if (_childrenInitialized || Converter == null || !HasValue || !PropertyDescriptorDescriptor.IsSupported) return; _childrenInitialized = true; Children.Clear(); - var properties = (IList)s_GetPropertiesMethod.Invoke(Converter, new object[] { Value }); + var properties = Converter.GetProperties(Value); if (properties == null) return;