Adds null reference checks for GetValue<T>.

Fixes #134
This commit is contained in:
leekelleher
2014-05-22 14:29:38 +01:00
parent 4785c85b84
commit 0cbbd1c93e
@@ -29,7 +29,7 @@ namespace Archetype.Models
{
var property = GetProperty(propertyAlias);
if (property == null || string.IsNullOrEmpty(property.Value.ToString()))
if (property == null || property.Value == null || string.IsNullOrEmpty(property.Value.ToString()))
return default(T);
return property.GetValue<T>();
@@ -43,7 +43,7 @@ namespace Archetype.Models
public bool HasValue(string propertyAlias)
{
var property = GetProperty(propertyAlias);
if (property == null)
if (property == null || property.Value == null)
return false;
return !string.IsNullOrEmpty(property.Value.ToString());
@@ -57,4 +57,4 @@ namespace Archetype.Models
#endregion
}
}
}