Skip to content

Commit

Permalink
Fix The application eventually crashes #5
Browse files Browse the repository at this point in the history
  • Loading branch information
microspaze committed Mar 29, 2024
1 parent 2933eda commit 49556e6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
7 changes: 4 additions & 3 deletions RGPopup.Maui/Converters/TypeConverters/EasingTypeConverter.cs
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
using System.ComponentModel;
using System.Globalization;
using System.Reflection;

namespace RGPopup.Maui.Converters.TypeConverters
{
public class EasingTypeConverter : TypeConverter
{
public new object ConvertFromInvariantString(string value)
public override object? ConvertFrom(ITypeDescriptorContext? context, CultureInfo? culture, object value)
{
if (value != null)
{
var fieldInfo = typeof(Easing).GetRuntimeFields()?.FirstOrDefault(fi =>
{
if (fi.IsStatic)
return fi.Name == value;
return fi.Name == value.ToString();
return false;
});
if (fieldInfo != null)
return (Easing)fieldInfo.GetValue(null);
return fieldInfo.GetValue(null) as Easing;
}
throw new InvalidOperationException($"Cannot convert \"{value}\" into {typeof(Easing)}");
}
Expand Down
3 changes: 2 additions & 1 deletion RGPopup.Maui/Converters/TypeConverters/UintTypeConverter.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
using System.ComponentModel;
using System.Globalization;

namespace RGPopup.Maui.Converters.TypeConverters
{
public class UintTypeConverter : TypeConverter
{
public new object ConvertFromInvariantString(string value)
public override object? ConvertFrom(ITypeDescriptorContext? context, CultureInfo? culture, object value)
{
try
{
Expand Down

0 comments on commit 49556e6

Please sign in to comment.