-Fixed attributes on nullable structs not being used

-Fixed deserializing nullable enums
-Fixed JsonConstructorAttribute incorrectly being allowed on properties
-Added new NUnit
This commit is contained in:
JamesNK
2012-02-03 02:31:56 +00:00
parent c5f1074e70
commit 6ce847411a
34 changed files with 11050 additions and 17 deletions
@@ -530,18 +530,18 @@ namespace Newtonsoft.Json.Serialization
if (contract.IsConvertable)
{
if (targetType.IsEnum)
if (contract.NonNullableUnderlyingType.IsEnum)
{
if (value is string)
return Enum.Parse(targetType, value.ToString(), true);
return Enum.Parse(contract.NonNullableUnderlyingType, value.ToString(), true);
else if (ConvertUtils.IsInteger(value))
return Enum.ToObject(targetType, value);
return Enum.ToObject(contract.NonNullableUnderlyingType, value);
}
return Convert.ChangeType(value, contract.NonNullableUnderlyingType, culture);
}
return ConvertUtils.ConvertOrCast(value, culture, targetType);
return ConvertUtils.ConvertOrCast(value, culture, contract.NonNullableUnderlyingType);
}
catch (Exception ex)
{