-Added netstandard1.1 with BigInteger support

This commit is contained in:
James Newton-King
2016-09-10 23:54:44 +12:00
parent 5e278bdbae
commit 68d160f3c6
35 changed files with 194 additions and 132 deletions
+32 -32
View File
@@ -31,7 +31,7 @@ using System.Dynamic;
using System.Linq.Expressions;
#endif
using System.IO;
#if !(NET20 || NET35 || PORTABLE40 || PORTABLE)
#if !(NET20 || NET35 || PORTABLE40 || PORTABLE) || NETSTANDARD1_1
using System.Numerics;
#endif
using System.Text;
@@ -68,7 +68,7 @@ namespace Newtonsoft.Json.Linq
private static readonly JTokenType[] BooleanTypes = new[] { JTokenType.Integer, JTokenType.Float, JTokenType.String, JTokenType.Comment, JTokenType.Raw, JTokenType.Boolean };
private static readonly JTokenType[] NumberTypes = new[] { JTokenType.Integer, JTokenType.Float, JTokenType.String, JTokenType.Comment, JTokenType.Raw, JTokenType.Boolean };
#if !(NET20 || NET35 || PORTABLE40 || PORTABLE)
#if !(NET20 || NET35 || PORTABLE40 || PORTABLE) || NETSTANDARD1_1
private static readonly JTokenType[] BigIntegerTypes = new[] { JTokenType.Integer, JTokenType.Float, JTokenType.String, JTokenType.Comment, JTokenType.Raw, JTokenType.Boolean, JTokenType.Bytes };
#endif
private static readonly JTokenType[] StringTypes = new[] { JTokenType.Date, JTokenType.Integer, JTokenType.Float, JTokenType.String, JTokenType.Comment, JTokenType.Raw, JTokenType.Boolean, JTokenType.Bytes, JTokenType.Guid, JTokenType.TimeSpan, JTokenType.Uri };
@@ -492,7 +492,7 @@ namespace Newtonsoft.Json.Linq
throw new ArgumentException("Can not convert {0} to Boolean.".FormatWith(CultureInfo.InvariantCulture, GetType(value)));
}
#if !(NET20 || NET35 || PORTABLE40 || PORTABLE)
#if !(NET20 || NET35 || PORTABLE40 || PORTABLE) || NETSTANDARD1_1
if (v.Value is BigInteger)
{
return Convert.ToBoolean((int)(BigInteger)v.Value);
@@ -546,7 +546,7 @@ namespace Newtonsoft.Json.Linq
throw new ArgumentException("Can not convert {0} to Boolean.".FormatWith(CultureInfo.InvariantCulture, GetType(value)));
}
#if !(NET20 || NET35 || PORTABLE40 || PORTABLE)
#if !(NET20 || NET35 || PORTABLE40 || PORTABLE) || NETSTANDARD1_1
if (v.Value is BigInteger)
{
return Convert.ToBoolean((int)(BigInteger)v.Value);
@@ -569,7 +569,7 @@ namespace Newtonsoft.Json.Linq
throw new ArgumentException("Can not convert {0} to Int64.".FormatWith(CultureInfo.InvariantCulture, GetType(value)));
}
#if !(NET20 || NET35 || PORTABLE40 || PORTABLE)
#if !(NET20 || NET35 || PORTABLE40 || PORTABLE) || NETSTANDARD1_1
if (v.Value is BigInteger)
{
return (long)(BigInteger)v.Value;
@@ -660,7 +660,7 @@ namespace Newtonsoft.Json.Linq
throw new ArgumentException("Can not convert {0} to Decimal.".FormatWith(CultureInfo.InvariantCulture, GetType(value)));
}
#if !(NET20 || NET35 || PORTABLE40 || PORTABLE)
#if !(NET20 || NET35 || PORTABLE40 || PORTABLE) || NETSTANDARD1_1
if (v.Value is BigInteger)
{
return (decimal?)(BigInteger)v.Value;
@@ -688,7 +688,7 @@ namespace Newtonsoft.Json.Linq
throw new ArgumentException("Can not convert {0} to Double.".FormatWith(CultureInfo.InvariantCulture, GetType(value)));
}
#if !(NET20 || NET35 || PORTABLE40 || PORTABLE)
#if !(NET20 || NET35 || PORTABLE40 || PORTABLE) || NETSTANDARD1_1
if (v.Value is BigInteger)
{
return (double?)(BigInteger)v.Value;
@@ -716,7 +716,7 @@ namespace Newtonsoft.Json.Linq
throw new ArgumentException("Can not convert {0} to Char.".FormatWith(CultureInfo.InvariantCulture, GetType(value)));
}
#if !(NET20 || NET35 || PORTABLE40 || PORTABLE)
#if !(NET20 || NET35 || PORTABLE40 || PORTABLE) || NETSTANDARD1_1
if (v.Value is BigInteger)
{
return (char?)(BigInteger)v.Value;
@@ -739,7 +739,7 @@ namespace Newtonsoft.Json.Linq
throw new ArgumentException("Can not convert {0} to Int32.".FormatWith(CultureInfo.InvariantCulture, GetType(value)));
}
#if !(NET20 || NET35 || PORTABLE40 || PORTABLE)
#if !(NET20 || NET35 || PORTABLE40 || PORTABLE) || NETSTANDARD1_1
if (v.Value is BigInteger)
{
return (int)(BigInteger)v.Value;
@@ -762,7 +762,7 @@ namespace Newtonsoft.Json.Linq
throw new ArgumentException("Can not convert {0} to Int16.".FormatWith(CultureInfo.InvariantCulture, GetType(value)));
}
#if !(NET20 || NET35 || PORTABLE40 || PORTABLE)
#if !(NET20 || NET35 || PORTABLE40 || PORTABLE) || NETSTANDARD1_1
if (v.Value is BigInteger)
{
return (short)(BigInteger)v.Value;
@@ -786,7 +786,7 @@ namespace Newtonsoft.Json.Linq
throw new ArgumentException("Can not convert {0} to UInt16.".FormatWith(CultureInfo.InvariantCulture, GetType(value)));
}
#if !(NET20 || NET35 || PORTABLE40 || PORTABLE)
#if !(NET20 || NET35 || PORTABLE40 || PORTABLE) || NETSTANDARD1_1
if (v.Value is BigInteger)
{
return (ushort)(BigInteger)v.Value;
@@ -810,7 +810,7 @@ namespace Newtonsoft.Json.Linq
throw new ArgumentException("Can not convert {0} to Char.".FormatWith(CultureInfo.InvariantCulture, GetType(value)));
}
#if !(NET20 || NET35 || PORTABLE40 || PORTABLE)
#if !(NET20 || NET35 || PORTABLE40 || PORTABLE) || NETSTANDARD1_1
if (v.Value is BigInteger)
{
return (char)(BigInteger)v.Value;
@@ -833,7 +833,7 @@ namespace Newtonsoft.Json.Linq
throw new ArgumentException("Can not convert {0} to Byte.".FormatWith(CultureInfo.InvariantCulture, GetType(value)));
}
#if !(NET20 || NET35 || PORTABLE40 || PORTABLE)
#if !(NET20 || NET35 || PORTABLE40 || PORTABLE) || NETSTANDARD1_1
if (v.Value is BigInteger)
{
return (byte)(BigInteger)v.Value;
@@ -857,7 +857,7 @@ namespace Newtonsoft.Json.Linq
throw new ArgumentException("Can not convert {0} to SByte.".FormatWith(CultureInfo.InvariantCulture, GetType(value)));
}
#if !(NET20 || NET35 || PORTABLE40 || PORTABLE)
#if !(NET20 || NET35 || PORTABLE40 || PORTABLE) || NETSTANDARD1_1
if (v.Value is BigInteger)
{
return (sbyte)(BigInteger)v.Value;
@@ -885,7 +885,7 @@ namespace Newtonsoft.Json.Linq
throw new ArgumentException("Can not convert {0} to Int32.".FormatWith(CultureInfo.InvariantCulture, GetType(value)));
}
#if !(NET20 || NET35 || PORTABLE40 || PORTABLE)
#if !(NET20 || NET35 || PORTABLE40 || PORTABLE) || NETSTANDARD1_1
if (v.Value is BigInteger)
{
return (int?)(BigInteger)v.Value;
@@ -913,7 +913,7 @@ namespace Newtonsoft.Json.Linq
throw new ArgumentException("Can not convert {0} to Int16.".FormatWith(CultureInfo.InvariantCulture, GetType(value)));
}
#if !(NET20 || NET35 || PORTABLE40 || PORTABLE)
#if !(NET20 || NET35 || PORTABLE40 || PORTABLE) || NETSTANDARD1_1
if (v.Value is BigInteger)
{
return (short?)(BigInteger)v.Value;
@@ -942,7 +942,7 @@ namespace Newtonsoft.Json.Linq
throw new ArgumentException("Can not convert {0} to UInt16.".FormatWith(CultureInfo.InvariantCulture, GetType(value)));
}
#if !(NET20 || NET35 || PORTABLE40 || PORTABLE)
#if !(NET20 || NET35 || PORTABLE40 || PORTABLE) || NETSTANDARD1_1
if (v.Value is BigInteger)
{
return (ushort?)(BigInteger)v.Value;
@@ -970,7 +970,7 @@ namespace Newtonsoft.Json.Linq
throw new ArgumentException("Can not convert {0} to Byte.".FormatWith(CultureInfo.InvariantCulture, GetType(value)));
}
#if !(NET20 || NET35 || PORTABLE40 || PORTABLE)
#if !(NET20 || NET35 || PORTABLE40 || PORTABLE) || NETSTANDARD1_1
if (v.Value is BigInteger)
{
return (byte?)(BigInteger)v.Value;
@@ -999,7 +999,7 @@ namespace Newtonsoft.Json.Linq
throw new ArgumentException("Can not convert {0} to SByte.".FormatWith(CultureInfo.InvariantCulture, GetType(value)));
}
#if !(NET20 || NET35 || PORTABLE40 || PORTABLE)
#if !(NET20 || NET35 || PORTABLE40 || PORTABLE) || NETSTANDARD1_1
if (v.Value is BigInteger)
{
return (sbyte?)(BigInteger)v.Value;
@@ -1050,7 +1050,7 @@ namespace Newtonsoft.Json.Linq
throw new ArgumentException("Can not convert {0} to Int64.".FormatWith(CultureInfo.InvariantCulture, GetType(value)));
}
#if !(NET20 || NET35 || PORTABLE40 || PORTABLE)
#if !(NET20 || NET35 || PORTABLE40 || PORTABLE) || NETSTANDARD1_1
if (v.Value is BigInteger)
{
return (long?)(BigInteger)v.Value;
@@ -1078,7 +1078,7 @@ namespace Newtonsoft.Json.Linq
throw new ArgumentException("Can not convert {0} to Single.".FormatWith(CultureInfo.InvariantCulture, GetType(value)));
}
#if !(NET20 || NET35 || PORTABLE40 || PORTABLE)
#if !(NET20 || NET35 || PORTABLE40 || PORTABLE) || NETSTANDARD1_1
if (v.Value is BigInteger)
{
return (float?)(BigInteger)v.Value;
@@ -1101,7 +1101,7 @@ namespace Newtonsoft.Json.Linq
throw new ArgumentException("Can not convert {0} to Decimal.".FormatWith(CultureInfo.InvariantCulture, GetType(value)));
}
#if !(NET20 || NET35 || PORTABLE40 || PORTABLE)
#if !(NET20 || NET35 || PORTABLE40 || PORTABLE) || NETSTANDARD1_1
if (v.Value is BigInteger)
{
return (decimal)(BigInteger)v.Value;
@@ -1130,7 +1130,7 @@ namespace Newtonsoft.Json.Linq
throw new ArgumentException("Can not convert {0} to UInt32.".FormatWith(CultureInfo.InvariantCulture, GetType(value)));
}
#if !(NET20 || NET35 || PORTABLE40 || PORTABLE)
#if !(NET20 || NET35 || PORTABLE40 || PORTABLE) || NETSTANDARD1_1
if (v.Value is BigInteger)
{
return (uint?)(BigInteger)v.Value;
@@ -1159,7 +1159,7 @@ namespace Newtonsoft.Json.Linq
throw new ArgumentException("Can not convert {0} to UInt64.".FormatWith(CultureInfo.InvariantCulture, GetType(value)));
}
#if !(NET20 || NET35 || PORTABLE40 || PORTABLE)
#if !(NET20 || NET35 || PORTABLE40 || PORTABLE) || NETSTANDARD1_1
if (v.Value is BigInteger)
{
return (ulong?)(BigInteger)v.Value;
@@ -1182,7 +1182,7 @@ namespace Newtonsoft.Json.Linq
throw new ArgumentException("Can not convert {0} to Double.".FormatWith(CultureInfo.InvariantCulture, GetType(value)));
}
#if !(NET20 || NET35 || PORTABLE40 || PORTABLE)
#if !(NET20 || NET35 || PORTABLE40 || PORTABLE) || NETSTANDARD1_1
if (v.Value is BigInteger)
{
return (double)(BigInteger)v.Value;
@@ -1205,7 +1205,7 @@ namespace Newtonsoft.Json.Linq
throw new ArgumentException("Can not convert {0} to Single.".FormatWith(CultureInfo.InvariantCulture, GetType(value)));
}
#if !(NET20 || NET35 || PORTABLE40 || PORTABLE)
#if !(NET20 || NET35 || PORTABLE40 || PORTABLE) || NETSTANDARD1_1
if (v.Value is BigInteger)
{
return (float)(BigInteger)v.Value;
@@ -1241,7 +1241,7 @@ namespace Newtonsoft.Json.Linq
{
return Convert.ToBase64String((byte[])v.Value);
}
#if !(NET20 || NET35 || PORTABLE40 || PORTABLE)
#if !(NET20 || NET35 || PORTABLE40 || PORTABLE) || NETSTANDARD1_1
if (v.Value is BigInteger)
{
return ((BigInteger)v.Value).ToString(CultureInfo.InvariantCulture);
@@ -1265,7 +1265,7 @@ namespace Newtonsoft.Json.Linq
throw new ArgumentException("Can not convert {0} to UInt32.".FormatWith(CultureInfo.InvariantCulture, GetType(value)));
}
#if !(NET20 || NET35 || PORTABLE40 || PORTABLE)
#if !(NET20 || NET35 || PORTABLE40 || PORTABLE) || NETSTANDARD1_1
if (v.Value is BigInteger)
{
return (uint)(BigInteger)v.Value;
@@ -1289,7 +1289,7 @@ namespace Newtonsoft.Json.Linq
throw new ArgumentException("Can not convert {0} to UInt64.".FormatWith(CultureInfo.InvariantCulture, GetType(value)));
}
#if !(NET20 || NET35 || PORTABLE40 || PORTABLE)
#if !(NET20 || NET35 || PORTABLE40 || PORTABLE) || NETSTANDARD1_1
if (v.Value is BigInteger)
{
return (ulong)(BigInteger)v.Value;
@@ -1321,7 +1321,7 @@ namespace Newtonsoft.Json.Linq
{
return Convert.FromBase64String(Convert.ToString(v.Value, CultureInfo.InvariantCulture));
}
#if !(NET20 || NET35 || PORTABLE40 || PORTABLE)
#if !(NET20 || NET35 || PORTABLE40 || PORTABLE) || NETSTANDARD1_1
if (v.Value is BigInteger)
{
return ((BigInteger)v.Value).ToByteArray();
@@ -1456,7 +1456,7 @@ namespace Newtonsoft.Json.Linq
return (v.Value is Uri) ? (Uri)v.Value : new Uri(Convert.ToString(v.Value, CultureInfo.InvariantCulture));
}
#if !(NET20 || NET35 || PORTABLE40 || PORTABLE)
#if !(NET20 || NET35 || PORTABLE40 || PORTABLE) || NETSTANDARD1_1
private static BigInteger ToBigInteger(JToken value)
{
JValue v = EnsureValue(value);
@@ -2035,7 +2035,7 @@ namespace Newtonsoft.Json.Linq
return (TimeSpan?)this;
case PrimitiveTypeCode.TimeSpan:
return (TimeSpan)this;
#if !(NET20 || NET35 || PORTABLE40 || PORTABLE)
#if !(NET20 || NET35 || PORTABLE40 || PORTABLE) || NETSTANDARD1_1
case PrimitiveTypeCode.BigIntegerNullable:
return ToBigIntegerNullable(this);
case PrimitiveTypeCode.BigInteger: