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

Enums filtering support #34

Open
duhapunk opened this issue Dec 22, 2022 · 4 comments
Open

Enums filtering support #34

duhapunk opened this issue Dec 22, 2022 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@duhapunk
Copy link

Hello again! I noticed that your lib doesn't support enums. I fixed it like this:

if (property.PropertyType.IsEnum)
{
     Enum.TryParse(property.PropertyType, value.ToString(), true, out var result);
     return result; // additional checks required
}
@Kusumoto Kusumoto added the bug Something isn't working label Dec 26, 2022
@Kusumoto Kusumoto self-assigned this Dec 26, 2022
@n2pro-wa
Copy link

Works for me, @Kusumoto Could you release the fix?

@Kusumoto
Copy link
Owner

Kusumoto commented Mar 14, 2023

Works for me, @Kusumoto Could you release the fix?

I already try, it work but TryParse method just work for .NET Standard 2.0 only.

This is the major change because after support this I'll obsolete .NET Framework support.

@duhapunk
Copy link
Author

Did you try "manual" TryParse ? Something like this

try
{
   var val = Enum.Parse(property.PropertyType, value.ToString(), true);
   var result = Convert.ChangeType(val, property.PropertyType);
   // additional checks required
   return result;
}
catch (Exception ex)
{
   // do some stuff
   return null;
}

@garry-mitchell-coats-com
Copy link
Contributor

Enum filtering would be great, if this could be incorporated :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants