prevent crashing if the value isn't convertible to the appropriate type
This commit is contained in:
parent
1b426b22b6
commit
2eb9ed0146
@ -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>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user