Skip to content

Commit

Permalink
Merge pull request #2660 from cwensley/curtis/remove-unnecessary-refl…
Browse files Browse the repository at this point in the history
…ection

No need to use reflection anymore to get converter properties/supported
  • Loading branch information
cwensley committed Jun 3, 2024
2 parents 6a80f14 + ef5a1fe commit cba28b5
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 cba28b5

Please sign in to comment.