-Fixed serializing and deserializing flag enums with EnumMember attribute

-Fixed using a type converter on interfaces
-Fixed deserializing ISerializable objects that also implement IConvertible
-Fixed build
This commit is contained in:
James Newton-King
2013-05-24 19:16:02 +12:00
parent f68794d206
commit 1b63698c02
9 changed files with 592 additions and 63 deletions
@@ -407,9 +407,6 @@ namespace Newtonsoft.Json.Utilities
return FromBigInteger((BigInteger)initialValue, targetType);
#endif
if (targetType.IsInterface() || targetType.IsGenericTypeDefinition() || targetType.IsAbstract())
throw new ArgumentException("Target type {0} is not a value type or a non-abstract class.".FormatWith(CultureInfo.InvariantCulture, targetType), "targetType");
#if !(NETFX_CORE || PORTABLE40 || PORTABLE)
// see if source or target types have a TypeConverter that converts between the two
TypeConverter toConverter = GetConverter(initialType);
@@ -449,6 +446,9 @@ namespace Newtonsoft.Json.Utilities
return EnsureTypeAssignable(ToValue((INullable)initialValue), initialType, targetType);
#endif
if (targetType.IsInterface() || targetType.IsGenericTypeDefinition() || targetType.IsAbstract())
throw new ArgumentException("Target type {0} is not a value type or a non-abstract class.".FormatWith(CultureInfo.InvariantCulture, targetType), "targetType");
throw new InvalidOperationException("Can not convert from {0} to {1}.".FormatWith(CultureInfo.InvariantCulture, initialType, targetType));
}