-Refactor

This commit is contained in:
James Newton-King
2018-01-11 22:03:21 +13:00
parent c445141fc6
commit 66c41b5937
2 changed files with 16 additions and 17 deletions
+1 -8
View File
@@ -1776,14 +1776,7 @@ namespace Newtonsoft.Json
#if HAVE_ICONVERTIBLE
if (value is IConvertible convertible)
{
// the value is a non-standard IConvertible
// convert to the underlying value and retry
TypeInformation typeInformation = ConvertUtils.GetTypeInformation(convertible);
// if convertible has an underlying typecode of Object then attempt to convert it to a string
typeCode = typeInformation.TypeCode == PrimitiveTypeCode.Object ? PrimitiveTypeCode.String : typeInformation.TypeCode;
Type resolvedType = typeInformation.TypeCode == PrimitiveTypeCode.Object ? typeof(string) : typeInformation.Type;
value = convertible.ToType(resolvedType, CultureInfo.InvariantCulture);
ResolveConvertibleValue(convertible, out typeCode, out value);
continue;
}
#endif