prevent crashing if the value isn't convertible to the appropriate type

This commit is contained in:
Michael Becker 2020-05-13 06:36:09 -04:00
parent 1b426b22b6
commit 2eb9ed0146
No known key found for this signature in database
GPG Key ID: 506F54899E2BFED7

View File

@ -208,17 +208,28 @@ namespace UniversalEditor.ObjectModels.PropertyList
{
return (T)value;
}
if (String.IsNullOrEmpty((string)value))
return defaultValue;
Type t = typeof(T);
System.Reflection.MethodInfo miParse = t.GetMethod("Parse", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.Public, null, new Type[]
{
typeof(string)
}, null);
object retvalobj = miParse.Invoke(null, new object[]
try
{
value
});
return (T)retvalobj;
object retvalobj = miParse.Invoke(null, new object[]
{
value
});
return (T)retvalobj;
}
catch
{
return defaultValue;
}
}
/// <summary>