diff --git a/CSharp/Plugins/UniversalEditor.Essential/ObjectModels/PropertyList/PropertyListObjectModel.cs b/CSharp/Plugins/UniversalEditor.Essential/ObjectModels/PropertyList/PropertyListObjectModel.cs index 9ff946a0..b9f01c5c 100644 --- a/CSharp/Plugins/UniversalEditor.Essential/ObjectModels/PropertyList/PropertyListObjectModel.cs +++ b/CSharp/Plugins/UniversalEditor.Essential/ObjectModels/PropertyList/PropertyListObjectModel.cs @@ -152,15 +152,12 @@ namespace UniversalEditor.ObjectModels.PropertyList } else { - try - { - result = (T)parent.Properties[propertyPath[propertyPath.Length - 1]].Value; - } - catch (NullReferenceException) + Property p = parent.Properties[propertyPath[propertyPath.Length - 1]]; + if (p == null || p.Value == null) { result = defaultValue; } - catch (InvalidCastException) + else if (p.Value.GetType() != typeof(T) && p.Value.GetType() == typeof(String)) { Type t = typeof(T); MethodInfo miParse = t.GetMethod("Parse", BindingFlags.Static | BindingFlags.Public, null, new Type[] @@ -173,6 +170,30 @@ namespace UniversalEditor.ObjectModels.PropertyList }); result = (T)retvalobj; } + else + { + try + { + result = (T)parent.Properties[propertyPath[propertyPath.Length - 1]].Value; + } + catch (NullReferenceException) + { + result = defaultValue; + } + catch (InvalidCastException) + { + Type t = typeof(T); + MethodInfo miParse = t.GetMethod("Parse", BindingFlags.Static | BindingFlags.Public, null, new Type[] + { + typeof(string) + }, null); + object retvalobj = miParse.Invoke(null, new object[] + { + parent.Properties[propertyPath[propertyPath.Length - 1]].Value + }); + result = (T)retvalobj; + } + } } } }