Skip to content

Commit

Permalink
No need to use reflection anymore to get converter properties/supported
Browse files Browse the repository at this point in the history
  • Loading branch information
cwensley committed Jun 1, 2024
1 parent 36ca020 commit ef5a1fe
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions src/Eto/Forms/ThemedControls/ThemedPropertyGridHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -654,12 +646,12 @@ public void SetCollection(IEnumerable<object> 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;

Expand Down

0 comments on commit ef5a1fe

Please sign in to comment.