Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No need to use reflection anymore to get converter properties/supported #2660

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading