-Changed portable assembly to be .NET 4.5, WP8, Win8
This commit is contained in:
@@ -61,7 +61,7 @@ namespace Newtonsoft.Json.Tests
|
|||||||
Assert.AreEqual(JsonToken.Float, reader.TokenType);
|
Assert.AreEqual(JsonToken.Float, reader.TokenType);
|
||||||
|
|
||||||
Assert.IsTrue(reader.Read());
|
Assert.IsTrue(reader.Read());
|
||||||
Assert.AreEqual(1l, reader.Value);
|
Assert.AreEqual(1L, reader.Value);
|
||||||
Assert.AreEqual(typeof(long), reader.ValueType);
|
Assert.AreEqual(typeof(long), reader.ValueType);
|
||||||
Assert.AreEqual(JsonToken.Integer, reader.TokenType);
|
Assert.AreEqual(JsonToken.Integer, reader.TokenType);
|
||||||
|
|
||||||
|
|||||||
@@ -437,7 +437,7 @@ namespace Newtonsoft.Json.Tests.Linq
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !NETFX_CORE
|
#if !(NETFX_CORE || PORTABLE)
|
||||||
[Test]
|
[Test]
|
||||||
public void ConvertsToBoolean()
|
public void ConvertsToBoolean()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -75,4 +75,4 @@ using System.Security;
|
|||||||
// You can specify all the values or you can default the Revision and Build Numbers
|
// You can specify all the values or you can default the Revision and Build Numbers
|
||||||
// by using the '*' as shown below:
|
// by using the '*' as shown below:
|
||||||
[assembly: AssemblyVersion("4.5.0.0")]
|
[assembly: AssemblyVersion("4.5.0.0")]
|
||||||
[assembly: AssemblyFileVersion("5.0.1.15930")]
|
[assembly: AssemblyFileVersion("5.0.1.15931")]
|
||||||
|
|||||||
+1
-1
@@ -102,7 +102,7 @@ namespace Newtonsoft.Json.Tests.Serialization
|
|||||||
string json = o.ToString();
|
string json = o.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !NETFX_CORE
|
#if !(NETFX_CORE || PORTABLE)
|
||||||
[Test]
|
[Test]
|
||||||
public void MemberSearchFlags()
|
public void MemberSearchFlags()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -182,7 +182,7 @@ namespace Newtonsoft.Json.Tests.Serialization
|
|||||||
}", startingWithB);
|
}", startingWithB);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !NETFX_CORE
|
#if !(NETFX_CORE || PORTABLE)
|
||||||
[Test]
|
[Test]
|
||||||
public void SerializeCompilerGeneratedMembers()
|
public void SerializeCompilerGeneratedMembers()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -3336,6 +3336,7 @@ To fix this error either change the environment to be fully trusted, change the
|
|||||||
}", json);
|
}", json);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if !PORTABLE
|
||||||
[Test]
|
[Test]
|
||||||
public void DeserializeClassWithInheritedProtectedMember()
|
public void DeserializeClassWithInheritedProtectedMember()
|
||||||
{
|
{
|
||||||
@@ -3402,6 +3403,7 @@ To fix this error either change the environment to be fully trusted, change the
|
|||||||
Assert.AreEqual(3, ReflectionUtils.GetMemberValue(typeof(BB).GetProperty("BB_property7", BindingFlags.Instance | BindingFlags.Public), myB));
|
Assert.AreEqual(3, ReflectionUtils.GetMemberValue(typeof(BB).GetProperty("BB_property7", BindingFlags.Instance | BindingFlags.Public), myB));
|
||||||
Assert.AreEqual(3, ReflectionUtils.GetMemberValue(typeof(BB).GetProperty("BB_property8", BindingFlags.Instance | BindingFlags.Public), myB));
|
Assert.AreEqual(3, ReflectionUtils.GetMemberValue(typeof(BB).GetProperty("BB_property8", BindingFlags.Instance | BindingFlags.Public), myB));
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
public class AA
|
public class AA
|
||||||
{
|
{
|
||||||
@@ -6852,7 +6854,8 @@ Parameter name: value",
|
|||||||
Assert.AreEqual("[1.1,0.0,0.0]", json);
|
Assert.AreEqual("[1.1,0.0,0.0]", json);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !(NET20 || NET35 || NET40 || PORTABLE || SILVERLIGHT)
|
#if !(NET20 || NET35 || NET40 || SILVERLIGHT)
|
||||||
|
#if !PORTABLE
|
||||||
[Test]
|
[Test]
|
||||||
public void DeserializeReadOnlyListWithBigInteger()
|
public void DeserializeReadOnlyListWithBigInteger()
|
||||||
{
|
{
|
||||||
@@ -6867,6 +6870,22 @@ Parameter name: value",
|
|||||||
|
|
||||||
Assert.AreEqual(BigInteger.Parse("9000000000000000000000000000000000000000000000000"), nineQuindecillion);
|
Assert.AreEqual(BigInteger.Parse("9000000000000000000000000000000000000000000000000"), nineQuindecillion);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void DeserializeReadOnlyListWithInt()
|
||||||
|
{
|
||||||
|
string json = @"[
|
||||||
|
900
|
||||||
|
]";
|
||||||
|
|
||||||
|
var l = JsonConvert.DeserializeObject<IReadOnlyList<int>>(json);
|
||||||
|
|
||||||
|
int i = l[0];
|
||||||
|
// 900
|
||||||
|
|
||||||
|
Assert.AreEqual(900, i);
|
||||||
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void DeserializeReadOnlyListWithNullableType()
|
public void DeserializeReadOnlyListWithNullableType()
|
||||||
@@ -7833,9 +7852,9 @@ Parameter name: value",
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !(NET40 || NET35 || NET20 || SILVERLIGHT || WINDOWS_PHONE || PORTABLE)
|
#if !(NET40 || NET35 || NET20 || SILVERLIGHT || WINDOWS_PHONE)
|
||||||
[Test]
|
[Test]
|
||||||
public void DeserializeReadOnlyList()
|
public void DeserializeReadOnlyListInterface()
|
||||||
{
|
{
|
||||||
IReadOnlyList<int> list = JsonConvert.DeserializeObject<IReadOnlyList<int>>("[1,2,3]");
|
IReadOnlyList<int> list = JsonConvert.DeserializeObject<IReadOnlyList<int>>("[1,2,3]");
|
||||||
|
|
||||||
@@ -7846,7 +7865,7 @@ Parameter name: value",
|
|||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void DeserializeReadOnlyCollection()
|
public void DeserializeReadOnlyCollectionInterface()
|
||||||
{
|
{
|
||||||
IReadOnlyCollection<int> list = JsonConvert.DeserializeObject<IReadOnlyCollection<int>>("[1,2,3]");
|
IReadOnlyCollection<int> list = JsonConvert.DeserializeObject<IReadOnlyCollection<int>>("[1,2,3]");
|
||||||
|
|
||||||
@@ -7858,7 +7877,19 @@ Parameter name: value",
|
|||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void DeserializeReadOnlyDictionary()
|
public void DeserializeReadOnlyCollection()
|
||||||
|
{
|
||||||
|
ReadOnlyCollection<int> list = JsonConvert.DeserializeObject<ReadOnlyCollection<int>>("[1,2,3]");
|
||||||
|
|
||||||
|
Assert.AreEqual(3, list.Count);
|
||||||
|
|
||||||
|
Assert.AreEqual(1, list[0]);
|
||||||
|
Assert.AreEqual(2, list[1]);
|
||||||
|
Assert.AreEqual(3, list[2]);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void DeserializeReadOnlyDictionaryInterface()
|
||||||
{
|
{
|
||||||
IReadOnlyDictionary<string, int> dic = JsonConvert.DeserializeObject<IReadOnlyDictionary<string, int>>("{'one':1,'two':2}");
|
IReadOnlyDictionary<string, int> dic = JsonConvert.DeserializeObject<IReadOnlyDictionary<string, int>>("{'one':1,'two':2}");
|
||||||
|
|
||||||
@@ -7870,6 +7901,17 @@ Parameter name: value",
|
|||||||
CustomAssert.IsInstanceOfType(typeof(ReadOnlyDictionary<string, int>), dic);
|
CustomAssert.IsInstanceOfType(typeof(ReadOnlyDictionary<string, int>), dic);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void DeserializeReadOnlyDictionary()
|
||||||
|
{
|
||||||
|
ReadOnlyDictionary<string, int> dic = JsonConvert.DeserializeObject<ReadOnlyDictionary<string, int>>("{'one':1,'two':2}");
|
||||||
|
|
||||||
|
Assert.AreEqual(2, dic.Count);
|
||||||
|
|
||||||
|
Assert.AreEqual(1, dic["one"]);
|
||||||
|
Assert.AreEqual(2, dic["two"]);
|
||||||
|
}
|
||||||
|
|
||||||
public class CustomReadOnlyDictionary<TKey, TValue> : IReadOnlyDictionary<TKey, TValue>
|
public class CustomReadOnlyDictionary<TKey, TValue> : IReadOnlyDictionary<TKey, TValue>
|
||||||
{
|
{
|
||||||
private readonly IDictionary<TKey, TValue> _dictionary;
|
private readonly IDictionary<TKey, TValue> _dictionary;
|
||||||
|
|||||||
@@ -282,7 +282,7 @@ namespace Newtonsoft.Json.Tests.Serialization
|
|||||||
}", json);
|
}", json);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !SILVERLIGHT && !NETFX_CORE
|
#if !(SILVERLIGHT || NETFX_CORE || PORTABLE)
|
||||||
public class SerializationEventContextTestObject
|
public class SerializationEventContextTestObject
|
||||||
{
|
{
|
||||||
public string TestMember { get; set; }
|
public string TestMember { get; set; }
|
||||||
@@ -313,6 +313,7 @@ namespace Newtonsoft.Json.Tests.Serialization
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if !PORTABLE
|
||||||
public void WhenSerializationErrorDetectedBySerializer_ThenCallbackIsCalled()
|
public void WhenSerializationErrorDetectedBySerializer_ThenCallbackIsCalled()
|
||||||
{
|
{
|
||||||
// Verify contract is properly finding our callback
|
// Verify contract is properly finding our callback
|
||||||
@@ -336,7 +337,7 @@ namespace Newtonsoft.Json.Tests.Serialization
|
|||||||
// When fixed, this would pass.
|
// When fixed, this would pass.
|
||||||
Debug.Assert(foo.Identifier == 25);
|
Debug.Assert(foo.Identifier == 25);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
public class FooEvent
|
public class FooEvent
|
||||||
{
|
{
|
||||||
public int Identifier { get; set; }
|
public int Identifier { get; set; }
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ using System.Text;
|
|||||||
#if !NET20 && (!SILVERLIGHT || WINDOWS_PHONE)
|
#if !NET20 && (!SILVERLIGHT || WINDOWS_PHONE)
|
||||||
using System.Xml.Linq;
|
using System.Xml.Linq;
|
||||||
#endif
|
#endif
|
||||||
#if NETFX_CORE
|
#if NETFX_CORE || PORTABLE
|
||||||
using IConvertible = Newtonsoft.Json.Utilities.Convertible;
|
using IConvertible = Newtonsoft.Json.Utilities.Convertible;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -1261,7 +1261,7 @@ namespace Newtonsoft.Json
|
|||||||
numberValue = BigInteger.Parse(number, CultureInfo.InvariantCulture);
|
numberValue = BigInteger.Parse(number, CultureInfo.InvariantCulture);
|
||||||
#else
|
#else
|
||||||
// todo - validate number was a valid integer to make sure overflow was the reason for failure
|
// todo - validate number was a valid integer to make sure overflow was the reason for failure
|
||||||
throw JsonReaderException.Create((JsonReader)this, "JSON integer {0} is too large or small for an Int64.".FormatWith(CultureInfo.InvariantCulture, number));
|
throw JsonReaderException.Create(this, "JSON integer {0} is too large or small for an Int64.".FormatWith(CultureInfo.InvariantCulture, number));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ using System.Numerics;
|
|||||||
#endif
|
#endif
|
||||||
using Newtonsoft.Json.Utilities;
|
using Newtonsoft.Json.Utilities;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
#if NETFX_CORE
|
#if NETFX_CORE || PORTABLE
|
||||||
using IConvertible = Newtonsoft.Json.Utilities.Convertible;
|
using IConvertible = Newtonsoft.Json.Utilities.Convertible;
|
||||||
#endif
|
#endif
|
||||||
#if NET20
|
#if NET20
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ namespace Newtonsoft.Json.Linq
|
|||||||
/// Represents a value in JSON (string, integer, date, etc).
|
/// Represents a value in JSON (string, integer, date, etc).
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class JValue : JToken, IEquatable<JValue>, IFormattable, IComparable, IComparable<JValue>
|
public class JValue : JToken, IEquatable<JValue>, IFormattable, IComparable, IComparable<JValue>
|
||||||
#if !(NETFX_CORE)
|
#if !(NETFX_CORE || PORTABLE)
|
||||||
, IConvertible
|
, IConvertible
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
@@ -919,7 +919,7 @@ namespace Newtonsoft.Json.Linq
|
|||||||
return Compare(_valueType, _value, obj._value);
|
return Compare(_valueType, _value, obj._value);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !(NETFX_CORE)
|
#if !(NETFX_CORE || PORTABLE)
|
||||||
TypeCode IConvertible.GetTypeCode()
|
TypeCode IConvertible.GetTypeCode()
|
||||||
{
|
{
|
||||||
if (_value == null)
|
if (_value == null)
|
||||||
@@ -929,7 +929,7 @@ namespace Newtonsoft.Json.Linq
|
|||||||
if (_value is DateTimeOffset)
|
if (_value is DateTimeOffset)
|
||||||
return TypeCode.DateTime;
|
return TypeCode.DateTime;
|
||||||
#endif
|
#endif
|
||||||
#if !(NET20 || NET35 || SILVERLIGHT || PORTABLE)
|
#if !(NET20 || NET35 || SILVERLIGHT)
|
||||||
if (_value is BigInteger)
|
if (_value is BigInteger)
|
||||||
return TypeCode.Object;
|
return TypeCode.Object;
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -8,8 +8,8 @@
|
|||||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||||
<RootNamespace>Newtonsoft.Json</RootNamespace>
|
<RootNamespace>Newtonsoft.Json</RootNamespace>
|
||||||
<AssemblyName>Newtonsoft.Json</AssemblyName>
|
<AssemblyName>Newtonsoft.Json</AssemblyName>
|
||||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
||||||
<TargetFrameworkProfile>Profile158</TargetFrameworkProfile>
|
<TargetFrameworkProfile>Profile78</TargetFrameworkProfile>
|
||||||
<FileAlignment>512</FileAlignment>
|
<FileAlignment>512</FileAlignment>
|
||||||
<ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
<ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||||
<MinimumVisualStudioVersion>10.0</MinimumVisualStudioVersion>
|
<MinimumVisualStudioVersion>10.0</MinimumVisualStudioVersion>
|
||||||
|
|||||||
@@ -90,6 +90,6 @@ using System.Security;
|
|||||||
// You can specify all the values or you can default the Revision and Build Numbers
|
// You can specify all the values or you can default the Revision and Build Numbers
|
||||||
// by using the '*' as shown below:
|
// by using the '*' as shown below:
|
||||||
[assembly: AssemblyVersion("4.5.0.0")]
|
[assembly: AssemblyVersion("4.5.0.0")]
|
||||||
[assembly: AssemblyFileVersion("5.0.1.15930")]
|
[assembly: AssemblyFileVersion("5.0.1.15931")]
|
||||||
|
|
||||||
[assembly: CLSCompliant(true)]
|
[assembly: CLSCompliant(true)]
|
||||||
|
|||||||
@@ -136,7 +136,7 @@ namespace Newtonsoft.Json.Serialization
|
|||||||
get { return JsonTypeReflector.DynamicCodeGeneration; }
|
get { return JsonTypeReflector.DynamicCodeGeneration; }
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !NETFX_CORE
|
#if !(NETFX_CORE || PORTABLE)
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the default members search flags.
|
/// Gets or sets the default members search flags.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -656,11 +656,7 @@ namespace Newtonsoft.Json.Serialization
|
|||||||
while (current != null && current != typeof(object))
|
while (current != null && current != typeof(object))
|
||||||
{
|
{
|
||||||
ret.Add(current);
|
ret.Add(current);
|
||||||
#if NETFX_CORE
|
|
||||||
current = current.BaseType();
|
current = current.BaseType();
|
||||||
#else
|
|
||||||
current = current.BaseType;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return the class list in order of simple => complex
|
// Return the class list in order of simple => complex
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ namespace Newtonsoft.Json.Serialization
|
|||||||
#pragma warning disable 618,612
|
#pragma warning disable 618,612
|
||||||
assembly = Assembly.LoadWithPartialName(assemblyName);
|
assembly = Assembly.LoadWithPartialName(assemblyName);
|
||||||
#pragma warning restore 618,612
|
#pragma warning restore 618,612
|
||||||
#elif NETFX_CORE
|
#elif NETFX_CORE || PORTABLE
|
||||||
assembly = Assembly.Load(new AssemblyName(assemblyName));
|
assembly = Assembly.Load(new AssemblyName(assemblyName));
|
||||||
#else
|
#else
|
||||||
assembly = Assembly.Load(assemblyName);
|
assembly = Assembly.Load(assemblyName);
|
||||||
@@ -128,7 +128,7 @@ namespace Newtonsoft.Json.Serialization
|
|||||||
/// <param name="typeName">Specifies the <see cref="T:System.Type"/> name of the serialized object. </param>
|
/// <param name="typeName">Specifies the <see cref="T:System.Type"/> name of the serialized object. </param>
|
||||||
public override void BindToName(Type serializedType, out string assemblyName, out string typeName)
|
public override void BindToName(Type serializedType, out string assemblyName, out string typeName)
|
||||||
{
|
{
|
||||||
#if NETFX_CORE
|
#if NETFX_CORE || PORTABLE
|
||||||
assemblyName = serializedType.GetTypeInfo().Assembly.FullName;
|
assemblyName = serializedType.GetTypeInfo().Assembly.FullName;
|
||||||
typeName = serializedType.FullName;
|
typeName = serializedType.FullName;
|
||||||
#elif !SILVERLIGHT
|
#elif !SILVERLIGHT
|
||||||
|
|||||||
@@ -89,15 +89,6 @@ namespace Newtonsoft.Json.Serialization
|
|||||||
canDeserialize = true;
|
canDeserialize = true;
|
||||||
IsMultidimensionalArray = (UnderlyingType.IsArray && UnderlyingType.GetArrayRank() > 1);
|
IsMultidimensionalArray = (UnderlyingType.IsArray && UnderlyingType.GetArrayRank() > 1);
|
||||||
}
|
}
|
||||||
else if (ReflectionUtils.InheritsGenericDefinition(underlyingType, typeof(ReadOnlyCollection<>), out tempCollectionType))
|
|
||||||
{
|
|
||||||
CollectionItemType = tempCollectionType.GetGenericArguments()[0];
|
|
||||||
ParametrizedConstructor = CollectionUtils.ResolveEnumableCollectionConstructor(underlyingType, CollectionItemType);
|
|
||||||
|
|
||||||
IsReadOnlyOrFixedSize = true;
|
|
||||||
|
|
||||||
canDeserialize = (ParametrizedConstructor != null);
|
|
||||||
}
|
|
||||||
else if (typeof(IList).IsAssignableFrom(underlyingType))
|
else if (typeof(IList).IsAssignableFrom(underlyingType))
|
||||||
{
|
{
|
||||||
if (ReflectionUtils.ImplementsGenericDefinition(underlyingType, typeof(ICollection<>), out _genericCollectionDefinitionType))
|
if (ReflectionUtils.ImplementsGenericDefinition(underlyingType, typeof(ICollection<>), out _genericCollectionDefinitionType))
|
||||||
@@ -129,7 +120,7 @@ namespace Newtonsoft.Json.Serialization
|
|||||||
canDeserialize = true;
|
canDeserialize = true;
|
||||||
ShouldCreateWrapper = true;
|
ShouldCreateWrapper = true;
|
||||||
}
|
}
|
||||||
#if !(NET40 || NET35 || NET20 || SILVERLIGHT || WINDOWS_PHONE || PORTABLE)
|
#if !(NET40 || NET35 || NET20 || SILVERLIGHT || WINDOWS_PHONE)
|
||||||
else if (ReflectionUtils.ImplementsGenericDefinition(underlyingType, typeof (IReadOnlyCollection<>), out tempCollectionType))
|
else if (ReflectionUtils.ImplementsGenericDefinition(underlyingType, typeof (IReadOnlyCollection<>), out tempCollectionType))
|
||||||
{
|
{
|
||||||
CollectionItemType = underlyingType.GetGenericArguments()[0];
|
CollectionItemType = underlyingType.GetGenericArguments()[0];
|
||||||
@@ -195,45 +186,6 @@ namespace Newtonsoft.Json.Serialization
|
|||||||
}
|
}
|
||||||
|
|
||||||
internal IWrappedCollection CreateWrapper(object list)
|
internal IWrappedCollection CreateWrapper(object list)
|
||||||
{
|
|
||||||
if (_genericCollectionDefinitionType != null)
|
|
||||||
{
|
|
||||||
EnsureGenericWrapperCreator();
|
|
||||||
return (IWrappedCollection) _genericWrapperCreator(null, list);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
IList values = ((IEnumerable) list).Cast<object>().ToList();
|
|
||||||
|
|
||||||
if (CollectionItemType != null)
|
|
||||||
{
|
|
||||||
Array array = Array.CreateInstance(CollectionItemType, values.Count);
|
|
||||||
for (int i = 0; i < values.Count; i++)
|
|
||||||
{
|
|
||||||
array.SetValue(values[i], i);
|
|
||||||
}
|
|
||||||
|
|
||||||
values = array;
|
|
||||||
}
|
|
||||||
|
|
||||||
return new CollectionWrapper<object>(values);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
internal IList CreateTemporaryCollection()
|
|
||||||
{
|
|
||||||
if (_genericTemporaryCollectionCreator == null)
|
|
||||||
{
|
|
||||||
// multidimensional array will also have array instances in it
|
|
||||||
Type collectionItemType = (IsMultidimensionalArray) ? typeof (object) : CollectionItemType;
|
|
||||||
Type temporaryListType = ReflectionUtils.MakeGenericType(typeof(List<>), collectionItemType);
|
|
||||||
_genericTemporaryCollectionCreator = JsonTypeReflector.ReflectionDelegateFactory.CreateDefaultConstructor<object>(temporaryListType);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (IList)_genericTemporaryCollectionCreator();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void EnsureGenericWrapperCreator()
|
|
||||||
{
|
{
|
||||||
if (_genericWrapperCreator == null)
|
if (_genericWrapperCreator == null)
|
||||||
{
|
{
|
||||||
@@ -250,6 +202,21 @@ namespace Newtonsoft.Json.Serialization
|
|||||||
ConstructorInfo genericWrapperConstructor = _genericWrapperType.GetConstructor(new[] { constructorArgument });
|
ConstructorInfo genericWrapperConstructor = _genericWrapperType.GetConstructor(new[] { constructorArgument });
|
||||||
_genericWrapperCreator = JsonTypeReflector.ReflectionDelegateFactory.CreateMethodCall<object>(genericWrapperConstructor);
|
_genericWrapperCreator = JsonTypeReflector.ReflectionDelegateFactory.CreateMethodCall<object>(genericWrapperConstructor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return (IWrappedCollection) _genericWrapperCreator(null, list);
|
||||||
|
}
|
||||||
|
|
||||||
|
internal IList CreateTemporaryCollection()
|
||||||
|
{
|
||||||
|
if (_genericTemporaryCollectionCreator == null)
|
||||||
|
{
|
||||||
|
// multidimensional array will also have array instances in it
|
||||||
|
Type collectionItemType = (IsMultidimensionalArray) ? typeof (object) : CollectionItemType;
|
||||||
|
Type temporaryListType = ReflectionUtils.MakeGenericType(typeof(List<>), collectionItemType);
|
||||||
|
_genericTemporaryCollectionCreator = JsonTypeReflector.ReflectionDelegateFactory.CreateDefaultConstructor<object>(temporaryListType);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (IList)_genericTemporaryCollectionCreator();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -91,7 +91,7 @@ namespace Newtonsoft.Json.Serialization
|
|||||||
if (ReflectionUtils.IsGenericDefinition(UnderlyingType, typeof(IDictionary<,>)))
|
if (ReflectionUtils.IsGenericDefinition(UnderlyingType, typeof(IDictionary<,>)))
|
||||||
CreatedType = ReflectionUtils.MakeGenericType(typeof(Dictionary<,>), keyType, valueType);
|
CreatedType = ReflectionUtils.MakeGenericType(typeof(Dictionary<,>), keyType, valueType);
|
||||||
}
|
}
|
||||||
#if !(NET40 || NET35 || NET20 || SILVERLIGHT || WINDOWS_PHONE || PORTABLE)
|
#if !(NET40 || NET35 || NET20 || SILVERLIGHT || WINDOWS_PHONE)
|
||||||
else if (ReflectionUtils.ImplementsGenericDefinition(underlyingType, typeof(IReadOnlyDictionary<,>), out _genericCollectionDefinitionType))
|
else if (ReflectionUtils.ImplementsGenericDefinition(underlyingType, typeof(IReadOnlyDictionary<,>), out _genericCollectionDefinitionType))
|
||||||
{
|
{
|
||||||
keyType = _genericCollectionDefinitionType.GetGenericArguments()[0];
|
keyType = _genericCollectionDefinitionType.GetGenericArguments()[0];
|
||||||
@@ -114,20 +114,29 @@ namespace Newtonsoft.Json.Serialization
|
|||||||
if (keyType != null && valueType != null)
|
if (keyType != null && valueType != null)
|
||||||
ParametrizedConstructor = CollectionUtils.ResolveEnumableCollectionConstructor(CreatedType, ReflectionUtils.MakeGenericType(typeof(KeyValuePair<,>), keyType, valueType));
|
ParametrizedConstructor = CollectionUtils.ResolveEnumableCollectionConstructor(CreatedType, ReflectionUtils.MakeGenericType(typeof(KeyValuePair<,>), keyType, valueType));
|
||||||
|
|
||||||
ShouldCreateWrapper = !typeof (IDictionary).IsAssignableFrom(underlyingType);
|
ShouldCreateWrapper = !typeof (IDictionary).IsAssignableFrom(CreatedType);
|
||||||
|
|
||||||
DictionaryKeyType = keyType;
|
DictionaryKeyType = keyType;
|
||||||
DictionaryValueType = valueType;
|
DictionaryValueType = valueType;
|
||||||
|
|
||||||
if (DictionaryValueType != null)
|
if (DictionaryValueType != null)
|
||||||
_isDictionaryValueTypeNullableType = ReflectionUtils.IsNullableType(DictionaryValueType);
|
_isDictionaryValueTypeNullableType = ReflectionUtils.IsNullableType(DictionaryValueType);
|
||||||
|
|
||||||
|
#if (NET20 || NET35)
|
||||||
|
Type tempDictioanryType;
|
||||||
|
|
||||||
|
// bug in .NET 2.0 & 3.5 that Dictionary<TKey, Nullable<TValue>> throws an error when adding null via IDictionary[key] = object
|
||||||
|
// wrapper will handle calling Add(T) instead
|
||||||
|
if (_isDictionaryValueTypeNullableType
|
||||||
|
&& (ReflectionUtils.InheritsGenericDefinition(CreatedType, typeof(Dictionary<,>), out tempDictioanryType)))
|
||||||
|
{
|
||||||
|
ShouldCreateWrapper = true;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
internal IWrappedDictionary CreateWrapper(object dictionary)
|
internal IWrappedDictionary CreateWrapper(object dictionary)
|
||||||
{
|
{
|
||||||
if (dictionary is IDictionary && (DictionaryValueType == null || !_isDictionaryValueTypeNullableType))
|
|
||||||
return new DictionaryWrapper<object, object>((IDictionary)dictionary);
|
|
||||||
|
|
||||||
if (_genericWrapperCreator == null)
|
if (_genericWrapperCreator == null)
|
||||||
{
|
{
|
||||||
_genericWrapperType = ReflectionUtils.MakeGenericType(typeof(DictionaryWrapper<,>), DictionaryKeyType, DictionaryValueType);
|
_genericWrapperType = ReflectionUtils.MakeGenericType(typeof(DictionaryWrapper<,>), DictionaryKeyType, DictionaryValueType);
|
||||||
|
|||||||
@@ -1467,17 +1467,17 @@ To fix this error either change the environment to be fully trusted, change the
|
|||||||
}
|
}
|
||||||
else if (propertyContract.ContractType == JsonContractType.Dictionary)
|
else if (propertyContract.ContractType == JsonContractType.Dictionary)
|
||||||
{
|
{
|
||||||
JsonDictionaryContract jsonDictionaryContract = (JsonDictionaryContract)propertyContract;
|
JsonDictionaryContract dictionaryContract = (JsonDictionaryContract)propertyContract;
|
||||||
|
|
||||||
object createdObjectDictionary = property.ValueProvider.GetValue(createdObject);
|
object createdObjectDictionary = property.ValueProvider.GetValue(createdObject);
|
||||||
if (createdObjectDictionary != null)
|
if (createdObjectDictionary != null)
|
||||||
{
|
{
|
||||||
IWrappedDictionary createdObjectDictionaryWrapper = jsonDictionaryContract.CreateWrapper(createdObjectDictionary);
|
IDictionary targetDictionary = (dictionaryContract.ShouldCreateWrapper) ? dictionaryContract.CreateWrapper(createdObjectDictionary) : (IDictionary) createdObjectDictionary;
|
||||||
IWrappedDictionary newValues = jsonDictionaryContract.CreateWrapper(value);
|
IDictionary newValues = (dictionaryContract.ShouldCreateWrapper) ? dictionaryContract.CreateWrapper(value) : (IDictionary) value;
|
||||||
|
|
||||||
foreach (DictionaryEntry newValue in newValues)
|
foreach (DictionaryEntry newValue in newValues)
|
||||||
{
|
{
|
||||||
createdObjectDictionaryWrapper.Add(newValue.Key, newValue.Value);
|
targetDictionary.Add(newValue.Key, newValue.Value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -320,7 +320,7 @@ namespace Newtonsoft.Json.Serialization
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if SILVERLIGHT || NETFX_CORE
|
#if SILVERLIGHT || NETFX_CORE || PORTABLE
|
||||||
if (value is Guid || value is Uri || value is TimeSpan)
|
if (value is Guid || value is Uri || value is TimeSpan)
|
||||||
{
|
{
|
||||||
s = value.ToString();
|
s = value.ToString();
|
||||||
|
|||||||
@@ -106,7 +106,7 @@ namespace Newtonsoft.Json.Utilities
|
|||||||
return true;
|
return true;
|
||||||
if (ReflectionUtils.ImplementsGenericDefinition(type, typeof(IDictionary<,>)))
|
if (ReflectionUtils.ImplementsGenericDefinition(type, typeof(IDictionary<,>)))
|
||||||
return true;
|
return true;
|
||||||
#if !(NET40 || NET35 || NET20 || SILVERLIGHT || WINDOWS_PHONE || PORTABLE)
|
#if !(NET40 || NET35 || NET20 || SILVERLIGHT || WINDOWS_PHONE)
|
||||||
if (ReflectionUtils.ImplementsGenericDefinition(type, typeof(IReadOnlyDictionary<,>)))
|
if (ReflectionUtils.ImplementsGenericDefinition(type, typeof(IReadOnlyDictionary<,>)))
|
||||||
return true;
|
return true;
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -38,13 +38,13 @@ using Newtonsoft.Json.Utilities.LinqBridge;
|
|||||||
#if !(SILVERLIGHT || NETFX_CORE || PORTABLE)
|
#if !(SILVERLIGHT || NETFX_CORE || PORTABLE)
|
||||||
using System.Data.SqlTypes;
|
using System.Data.SqlTypes;
|
||||||
#endif
|
#endif
|
||||||
#if NETFX_CORE
|
#if NETFX_CORE || PORTABLE
|
||||||
using IConvertible = Newtonsoft.Json.Utilities.Convertible;
|
using IConvertible = Newtonsoft.Json.Utilities.Convertible;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace Newtonsoft.Json.Utilities
|
namespace Newtonsoft.Json.Utilities
|
||||||
{
|
{
|
||||||
#if NETFX_CORE
|
#if NETFX_CORE || PORTABLE
|
||||||
internal class Convertible
|
internal class Convertible
|
||||||
{
|
{
|
||||||
private object _underlyingValue;
|
private object _underlyingValue;
|
||||||
@@ -130,7 +130,7 @@ namespace Newtonsoft.Json.Utilities
|
|||||||
{
|
{
|
||||||
public static TypeCode GetTypeCode(this IConvertible convertible)
|
public static TypeCode GetTypeCode(this IConvertible convertible)
|
||||||
{
|
{
|
||||||
#if !NETFX_CORE
|
#if !(NETFX_CORE || PORTABLE)
|
||||||
return convertible.GetTypeCode();
|
return convertible.GetTypeCode();
|
||||||
#else
|
#else
|
||||||
return GetTypeCode((object)convertible);
|
return GetTypeCode((object)convertible);
|
||||||
@@ -148,7 +148,7 @@ namespace Newtonsoft.Json.Utilities
|
|||||||
|
|
||||||
public static TypeCode GetTypeCode(Type t)
|
public static TypeCode GetTypeCode(Type t)
|
||||||
{
|
{
|
||||||
#if !NETFX_CORE
|
#if !(NETFX_CORE || PORTABLE)
|
||||||
return Type.GetTypeCode(t);
|
return Type.GetTypeCode(t);
|
||||||
#else
|
#else
|
||||||
if (t == typeof(bool))
|
if (t == typeof(bool))
|
||||||
@@ -190,7 +190,7 @@ namespace Newtonsoft.Json.Utilities
|
|||||||
|
|
||||||
public static IConvertible ToConvertible(object o)
|
public static IConvertible ToConvertible(object o)
|
||||||
{
|
{
|
||||||
#if !NETFX_CORE
|
#if !(NETFX_CORE || PORTABLE)
|
||||||
return o as IConvertible;
|
return o as IConvertible;
|
||||||
#else
|
#else
|
||||||
if (!IsConvertible(o))
|
if (!IsConvertible(o))
|
||||||
@@ -202,7 +202,7 @@ namespace Newtonsoft.Json.Utilities
|
|||||||
|
|
||||||
public static bool IsConvertible(object o)
|
public static bool IsConvertible(object o)
|
||||||
{
|
{
|
||||||
#if !NETFX_CORE
|
#if !(NETFX_CORE || PORTABLE)
|
||||||
return o is IConvertible;
|
return o is IConvertible;
|
||||||
#else
|
#else
|
||||||
if (o == null)
|
if (o == null)
|
||||||
@@ -216,7 +216,7 @@ namespace Newtonsoft.Json.Utilities
|
|||||||
|
|
||||||
public static bool IsConvertible(Type t)
|
public static bool IsConvertible(Type t)
|
||||||
{
|
{
|
||||||
#if !NETFX_CORE
|
#if !(NETFX_CORE || PORTABLE)
|
||||||
return typeof(IConvertible).IsAssignableFrom(t);
|
return typeof(IConvertible).IsAssignableFrom(t);
|
||||||
#else
|
#else
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ namespace Newtonsoft.Json.Utilities
|
|||||||
{
|
{
|
||||||
private readonly IDictionary _dictionary;
|
private readonly IDictionary _dictionary;
|
||||||
private readonly IDictionary<TKey, TValue> _genericDictionary;
|
private readonly IDictionary<TKey, TValue> _genericDictionary;
|
||||||
#if !(NET40 || NET35 || NET20 || SILVERLIGHT || WINDOWS_PHONE || PORTABLE)
|
#if !(NET40 || NET35 || NET20 || SILVERLIGHT || WINDOWS_PHONE)
|
||||||
private readonly IReadOnlyDictionary<TKey, TValue> _readOnlyDictionary;
|
private readonly IReadOnlyDictionary<TKey, TValue> _readOnlyDictionary;
|
||||||
#endif
|
#endif
|
||||||
private object _syncRoot;
|
private object _syncRoot;
|
||||||
@@ -64,7 +64,7 @@ namespace Newtonsoft.Json.Utilities
|
|||||||
_genericDictionary = dictionary;
|
_genericDictionary = dictionary;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !(NET40 || NET35 || NET20 || SILVERLIGHT || WINDOWS_PHONE || PORTABLE)
|
#if !(NET40 || NET35 || NET20 || SILVERLIGHT || WINDOWS_PHONE)
|
||||||
public DictionaryWrapper(IReadOnlyDictionary<TKey, TValue> dictionary)
|
public DictionaryWrapper(IReadOnlyDictionary<TKey, TValue> dictionary)
|
||||||
{
|
{
|
||||||
ValidationUtils.ArgumentNotNull(dictionary, "dictionary");
|
ValidationUtils.ArgumentNotNull(dictionary, "dictionary");
|
||||||
@@ -87,7 +87,7 @@ namespace Newtonsoft.Json.Utilities
|
|||||||
{
|
{
|
||||||
if (_dictionary != null)
|
if (_dictionary != null)
|
||||||
return _dictionary.Contains(key);
|
return _dictionary.Contains(key);
|
||||||
#if !(NET40 || NET35 || NET20 || SILVERLIGHT || WINDOWS_PHONE || PORTABLE)
|
#if !(NET40 || NET35 || NET20 || SILVERLIGHT || WINDOWS_PHONE)
|
||||||
else if (_readOnlyDictionary != null)
|
else if (_readOnlyDictionary != null)
|
||||||
return _readOnlyDictionary.ContainsKey(key);
|
return _readOnlyDictionary.ContainsKey(key);
|
||||||
#endif
|
#endif
|
||||||
@@ -101,7 +101,7 @@ namespace Newtonsoft.Json.Utilities
|
|||||||
{
|
{
|
||||||
if (_dictionary != null)
|
if (_dictionary != null)
|
||||||
return _dictionary.Keys.Cast<TKey>().ToList();
|
return _dictionary.Keys.Cast<TKey>().ToList();
|
||||||
#if !(NET40 || NET35 || NET20 || SILVERLIGHT || WINDOWS_PHONE || PORTABLE)
|
#if !(NET40 || NET35 || NET20 || SILVERLIGHT || WINDOWS_PHONE)
|
||||||
else if (_readOnlyDictionary != null)
|
else if (_readOnlyDictionary != null)
|
||||||
return _readOnlyDictionary.Keys.ToList();
|
return _readOnlyDictionary.Keys.ToList();
|
||||||
#endif
|
#endif
|
||||||
@@ -124,7 +124,7 @@ namespace Newtonsoft.Json.Utilities
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#if !(NET40 || NET35 || NET20 || SILVERLIGHT || WINDOWS_PHONE || PORTABLE)
|
#if !(NET40 || NET35 || NET20 || SILVERLIGHT || WINDOWS_PHONE)
|
||||||
else if (_readOnlyDictionary != null)
|
else if (_readOnlyDictionary != null)
|
||||||
{
|
{
|
||||||
throw new NotSupportedException();
|
throw new NotSupportedException();
|
||||||
@@ -151,7 +151,7 @@ namespace Newtonsoft.Json.Utilities
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#if !(NET40 || NET35 || NET20 || SILVERLIGHT || WINDOWS_PHONE || PORTABLE)
|
#if !(NET40 || NET35 || NET20 || SILVERLIGHT || WINDOWS_PHONE)
|
||||||
else if (_readOnlyDictionary != null)
|
else if (_readOnlyDictionary != null)
|
||||||
{
|
{
|
||||||
throw new NotSupportedException();
|
throw new NotSupportedException();
|
||||||
@@ -169,7 +169,7 @@ namespace Newtonsoft.Json.Utilities
|
|||||||
{
|
{
|
||||||
if (_dictionary != null)
|
if (_dictionary != null)
|
||||||
return _dictionary.Values.Cast<TValue>().ToList();
|
return _dictionary.Values.Cast<TValue>().ToList();
|
||||||
#if !(NET40 || NET35 || NET20 || SILVERLIGHT || WINDOWS_PHONE || PORTABLE)
|
#if !(NET40 || NET35 || NET20 || SILVERLIGHT || WINDOWS_PHONE)
|
||||||
else if (_readOnlyDictionary != null)
|
else if (_readOnlyDictionary != null)
|
||||||
return _readOnlyDictionary.Values.ToList();
|
return _readOnlyDictionary.Values.ToList();
|
||||||
#endif
|
#endif
|
||||||
@@ -184,7 +184,7 @@ namespace Newtonsoft.Json.Utilities
|
|||||||
{
|
{
|
||||||
if (_dictionary != null)
|
if (_dictionary != null)
|
||||||
return (TValue)_dictionary[key];
|
return (TValue)_dictionary[key];
|
||||||
#if !(NET40 || NET35 || NET20 || SILVERLIGHT || WINDOWS_PHONE || PORTABLE)
|
#if !(NET40 || NET35 || NET20 || SILVERLIGHT || WINDOWS_PHONE)
|
||||||
else if (_readOnlyDictionary != null)
|
else if (_readOnlyDictionary != null)
|
||||||
return _readOnlyDictionary[key];
|
return _readOnlyDictionary[key];
|
||||||
#endif
|
#endif
|
||||||
@@ -195,7 +195,7 @@ namespace Newtonsoft.Json.Utilities
|
|||||||
{
|
{
|
||||||
if (_dictionary != null)
|
if (_dictionary != null)
|
||||||
_dictionary[key] = value;
|
_dictionary[key] = value;
|
||||||
#if !(NET40 || NET35 || NET20 || SILVERLIGHT || WINDOWS_PHONE || PORTABLE)
|
#if !(NET40 || NET35 || NET20 || SILVERLIGHT || WINDOWS_PHONE)
|
||||||
else if (_readOnlyDictionary != null)
|
else if (_readOnlyDictionary != null)
|
||||||
throw new NotSupportedException();
|
throw new NotSupportedException();
|
||||||
#endif
|
#endif
|
||||||
@@ -208,7 +208,7 @@ namespace Newtonsoft.Json.Utilities
|
|||||||
{
|
{
|
||||||
if (_dictionary != null)
|
if (_dictionary != null)
|
||||||
((IList)_dictionary).Add(item);
|
((IList)_dictionary).Add(item);
|
||||||
#if !(NET40 || NET35 || NET20 || SILVERLIGHT || WINDOWS_PHONE || PORTABLE)
|
#if !(NET40 || NET35 || NET20 || SILVERLIGHT || WINDOWS_PHONE)
|
||||||
else if (_readOnlyDictionary != null)
|
else if (_readOnlyDictionary != null)
|
||||||
throw new NotSupportedException();
|
throw new NotSupportedException();
|
||||||
#endif
|
#endif
|
||||||
@@ -220,7 +220,7 @@ namespace Newtonsoft.Json.Utilities
|
|||||||
{
|
{
|
||||||
if (_dictionary != null)
|
if (_dictionary != null)
|
||||||
_dictionary.Clear();
|
_dictionary.Clear();
|
||||||
#if !(NET40 || NET35 || NET20 || SILVERLIGHT || WINDOWS_PHONE || PORTABLE)
|
#if !(NET40 || NET35 || NET20 || SILVERLIGHT || WINDOWS_PHONE)
|
||||||
else if (_readOnlyDictionary != null)
|
else if (_readOnlyDictionary != null)
|
||||||
throw new NotSupportedException();
|
throw new NotSupportedException();
|
||||||
#endif
|
#endif
|
||||||
@@ -232,7 +232,7 @@ namespace Newtonsoft.Json.Utilities
|
|||||||
{
|
{
|
||||||
if (_dictionary != null)
|
if (_dictionary != null)
|
||||||
return ((IList)_dictionary).Contains(item);
|
return ((IList)_dictionary).Contains(item);
|
||||||
#if !(NET40 || NET35 || NET20 || SILVERLIGHT || WINDOWS_PHONE || PORTABLE)
|
#if !(NET40 || NET35 || NET20 || SILVERLIGHT || WINDOWS_PHONE)
|
||||||
else if (_readOnlyDictionary != null)
|
else if (_readOnlyDictionary != null)
|
||||||
return _readOnlyDictionary.Contains(item);
|
return _readOnlyDictionary.Contains(item);
|
||||||
#endif
|
#endif
|
||||||
@@ -249,7 +249,7 @@ namespace Newtonsoft.Json.Utilities
|
|||||||
array[arrayIndex++] = new KeyValuePair<TKey, TValue>((TKey)item.Key, (TValue)item.Value);
|
array[arrayIndex++] = new KeyValuePair<TKey, TValue>((TKey)item.Key, (TValue)item.Value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#if !(NET40 || NET35 || NET20 || SILVERLIGHT || WINDOWS_PHONE || PORTABLE)
|
#if !(NET40 || NET35 || NET20 || SILVERLIGHT || WINDOWS_PHONE)
|
||||||
else if (_readOnlyDictionary != null)
|
else if (_readOnlyDictionary != null)
|
||||||
{
|
{
|
||||||
throw new NotSupportedException();
|
throw new NotSupportedException();
|
||||||
@@ -267,7 +267,7 @@ namespace Newtonsoft.Json.Utilities
|
|||||||
{
|
{
|
||||||
if (_dictionary != null)
|
if (_dictionary != null)
|
||||||
return _dictionary.Count;
|
return _dictionary.Count;
|
||||||
#if !(NET40 || NET35 || NET20 || SILVERLIGHT || WINDOWS_PHONE || PORTABLE)
|
#if !(NET40 || NET35 || NET20 || SILVERLIGHT || WINDOWS_PHONE)
|
||||||
else if (_readOnlyDictionary != null)
|
else if (_readOnlyDictionary != null)
|
||||||
return _readOnlyDictionary.Count;
|
return _readOnlyDictionary.Count;
|
||||||
#endif
|
#endif
|
||||||
@@ -282,7 +282,7 @@ namespace Newtonsoft.Json.Utilities
|
|||||||
{
|
{
|
||||||
if (_dictionary != null)
|
if (_dictionary != null)
|
||||||
return _dictionary.IsReadOnly;
|
return _dictionary.IsReadOnly;
|
||||||
#if !(NET40 || NET35 || NET20 || SILVERLIGHT || WINDOWS_PHONE || PORTABLE)
|
#if !(NET40 || NET35 || NET20 || SILVERLIGHT || WINDOWS_PHONE)
|
||||||
else if (_readOnlyDictionary != null)
|
else if (_readOnlyDictionary != null)
|
||||||
return true;
|
return true;
|
||||||
#endif
|
#endif
|
||||||
@@ -314,7 +314,7 @@ namespace Newtonsoft.Json.Utilities
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#if !(NET40 || NET35 || NET20 || SILVERLIGHT || WINDOWS_PHONE || PORTABLE)
|
#if !(NET40 || NET35 || NET20 || SILVERLIGHT || WINDOWS_PHONE)
|
||||||
else if (_readOnlyDictionary != null)
|
else if (_readOnlyDictionary != null)
|
||||||
{
|
{
|
||||||
throw new NotSupportedException();
|
throw new NotSupportedException();
|
||||||
@@ -330,7 +330,7 @@ namespace Newtonsoft.Json.Utilities
|
|||||||
{
|
{
|
||||||
if (_dictionary != null)
|
if (_dictionary != null)
|
||||||
return _dictionary.Cast<DictionaryEntry>().Select(de => new KeyValuePair<TKey, TValue>((TKey)de.Key, (TValue)de.Value)).GetEnumerator();
|
return _dictionary.Cast<DictionaryEntry>().Select(de => new KeyValuePair<TKey, TValue>((TKey)de.Key, (TValue)de.Value)).GetEnumerator();
|
||||||
#if !(NET40 || NET35 || NET20 || SILVERLIGHT || WINDOWS_PHONE || PORTABLE)
|
#if !(NET40 || NET35 || NET20 || SILVERLIGHT || WINDOWS_PHONE)
|
||||||
else if (_readOnlyDictionary != null)
|
else if (_readOnlyDictionary != null)
|
||||||
return _readOnlyDictionary.GetEnumerator();
|
return _readOnlyDictionary.GetEnumerator();
|
||||||
#endif
|
#endif
|
||||||
@@ -347,7 +347,7 @@ namespace Newtonsoft.Json.Utilities
|
|||||||
{
|
{
|
||||||
if (_dictionary != null)
|
if (_dictionary != null)
|
||||||
_dictionary.Add(key, value);
|
_dictionary.Add(key, value);
|
||||||
#if !(NET40 || NET35 || NET20 || SILVERLIGHT || WINDOWS_PHONE || PORTABLE)
|
#if !(NET40 || NET35 || NET20 || SILVERLIGHT || WINDOWS_PHONE)
|
||||||
else if (_readOnlyDictionary != null)
|
else if (_readOnlyDictionary != null)
|
||||||
throw new NotSupportedException();
|
throw new NotSupportedException();
|
||||||
#endif
|
#endif
|
||||||
@@ -361,7 +361,7 @@ namespace Newtonsoft.Json.Utilities
|
|||||||
{
|
{
|
||||||
if (_dictionary != null)
|
if (_dictionary != null)
|
||||||
return _dictionary[key];
|
return _dictionary[key];
|
||||||
#if !(NET40 || NET35 || NET20 || SILVERLIGHT || WINDOWS_PHONE || PORTABLE)
|
#if !(NET40 || NET35 || NET20 || SILVERLIGHT || WINDOWS_PHONE)
|
||||||
else if (_readOnlyDictionary != null)
|
else if (_readOnlyDictionary != null)
|
||||||
return _readOnlyDictionary[(TKey)key];
|
return _readOnlyDictionary[(TKey)key];
|
||||||
#endif
|
#endif
|
||||||
@@ -372,7 +372,7 @@ namespace Newtonsoft.Json.Utilities
|
|||||||
{
|
{
|
||||||
if (_dictionary != null)
|
if (_dictionary != null)
|
||||||
_dictionary[key] = value;
|
_dictionary[key] = value;
|
||||||
#if !(NET40 || NET35 || NET20 || SILVERLIGHT || WINDOWS_PHONE || PORTABLE)
|
#if !(NET40 || NET35 || NET20 || SILVERLIGHT || WINDOWS_PHONE)
|
||||||
else if (_readOnlyDictionary != null)
|
else if (_readOnlyDictionary != null)
|
||||||
throw new NotSupportedException();
|
throw new NotSupportedException();
|
||||||
#endif
|
#endif
|
||||||
@@ -426,7 +426,7 @@ namespace Newtonsoft.Json.Utilities
|
|||||||
{
|
{
|
||||||
if (_dictionary != null)
|
if (_dictionary != null)
|
||||||
return _dictionary.GetEnumerator();
|
return _dictionary.GetEnumerator();
|
||||||
#if !(NET40 || NET35 || NET20 || SILVERLIGHT || WINDOWS_PHONE || PORTABLE)
|
#if !(NET40 || NET35 || NET20 || SILVERLIGHT || WINDOWS_PHONE)
|
||||||
else if (_readOnlyDictionary != null)
|
else if (_readOnlyDictionary != null)
|
||||||
return new DictionaryEnumerator<TKey, TValue>(_readOnlyDictionary.GetEnumerator());
|
return new DictionaryEnumerator<TKey, TValue>(_readOnlyDictionary.GetEnumerator());
|
||||||
#endif
|
#endif
|
||||||
@@ -438,7 +438,7 @@ namespace Newtonsoft.Json.Utilities
|
|||||||
{
|
{
|
||||||
if (_genericDictionary != null)
|
if (_genericDictionary != null)
|
||||||
return _genericDictionary.ContainsKey((TKey)key);
|
return _genericDictionary.ContainsKey((TKey)key);
|
||||||
#if !(NET40 || NET35 || NET20 || SILVERLIGHT || WINDOWS_PHONE || PORTABLE)
|
#if !(NET40 || NET35 || NET20 || SILVERLIGHT || WINDOWS_PHONE)
|
||||||
else if (_readOnlyDictionary != null)
|
else if (_readOnlyDictionary != null)
|
||||||
return _readOnlyDictionary.ContainsKey((TKey)key);
|
return _readOnlyDictionary.ContainsKey((TKey)key);
|
||||||
#endif
|
#endif
|
||||||
@@ -452,7 +452,7 @@ namespace Newtonsoft.Json.Utilities
|
|||||||
{
|
{
|
||||||
if (_genericDictionary != null)
|
if (_genericDictionary != null)
|
||||||
return false;
|
return false;
|
||||||
#if !(NET40 || NET35 || NET20 || SILVERLIGHT || WINDOWS_PHONE || PORTABLE)
|
#if !(NET40 || NET35 || NET20 || SILVERLIGHT || WINDOWS_PHONE)
|
||||||
else if (_readOnlyDictionary != null)
|
else if (_readOnlyDictionary != null)
|
||||||
return true;
|
return true;
|
||||||
#endif
|
#endif
|
||||||
@@ -467,7 +467,7 @@ namespace Newtonsoft.Json.Utilities
|
|||||||
{
|
{
|
||||||
if (_genericDictionary != null)
|
if (_genericDictionary != null)
|
||||||
return _genericDictionary.Keys.ToList();
|
return _genericDictionary.Keys.ToList();
|
||||||
#if !(NET40 || NET35 || NET20 || SILVERLIGHT || WINDOWS_PHONE || PORTABLE)
|
#if !(NET40 || NET35 || NET20 || SILVERLIGHT || WINDOWS_PHONE)
|
||||||
else if (_readOnlyDictionary != null)
|
else if (_readOnlyDictionary != null)
|
||||||
return _readOnlyDictionary.Keys.ToList();
|
return _readOnlyDictionary.Keys.ToList();
|
||||||
#endif
|
#endif
|
||||||
@@ -480,7 +480,7 @@ namespace Newtonsoft.Json.Utilities
|
|||||||
{
|
{
|
||||||
if (_dictionary != null)
|
if (_dictionary != null)
|
||||||
_dictionary.Remove(key);
|
_dictionary.Remove(key);
|
||||||
#if !(NET40 || NET35 || NET20 || SILVERLIGHT || WINDOWS_PHONE || PORTABLE)
|
#if !(NET40 || NET35 || NET20 || SILVERLIGHT || WINDOWS_PHONE)
|
||||||
else if (_readOnlyDictionary != null)
|
else if (_readOnlyDictionary != null)
|
||||||
throw new NotSupportedException();
|
throw new NotSupportedException();
|
||||||
#endif
|
#endif
|
||||||
@@ -494,7 +494,7 @@ namespace Newtonsoft.Json.Utilities
|
|||||||
{
|
{
|
||||||
if (_genericDictionary != null)
|
if (_genericDictionary != null)
|
||||||
return _genericDictionary.Values.ToList();
|
return _genericDictionary.Values.ToList();
|
||||||
#if !(NET40 || NET35 || NET20 || SILVERLIGHT || WINDOWS_PHONE || PORTABLE)
|
#if !(NET40 || NET35 || NET20 || SILVERLIGHT || WINDOWS_PHONE)
|
||||||
else if (_readOnlyDictionary != null)
|
else if (_readOnlyDictionary != null)
|
||||||
return _readOnlyDictionary.Values.ToList();
|
return _readOnlyDictionary.Values.ToList();
|
||||||
#endif
|
#endif
|
||||||
@@ -507,7 +507,7 @@ namespace Newtonsoft.Json.Utilities
|
|||||||
{
|
{
|
||||||
if (_dictionary != null)
|
if (_dictionary != null)
|
||||||
_dictionary.CopyTo(array, index);
|
_dictionary.CopyTo(array, index);
|
||||||
#if !(NET40 || NET35 || NET20 || SILVERLIGHT || WINDOWS_PHONE || PORTABLE)
|
#if !(NET40 || NET35 || NET20 || SILVERLIGHT || WINDOWS_PHONE)
|
||||||
else if (_readOnlyDictionary != null)
|
else if (_readOnlyDictionary != null)
|
||||||
throw new NotSupportedException();
|
throw new NotSupportedException();
|
||||||
#endif
|
#endif
|
||||||
@@ -543,7 +543,7 @@ namespace Newtonsoft.Json.Utilities
|
|||||||
{
|
{
|
||||||
if (_dictionary != null)
|
if (_dictionary != null)
|
||||||
return _dictionary;
|
return _dictionary;
|
||||||
#if !(NET40 || NET35 || NET20 || SILVERLIGHT || WINDOWS_PHONE || PORTABLE)
|
#if !(NET40 || NET35 || NET20 || SILVERLIGHT || WINDOWS_PHONE)
|
||||||
else if (_readOnlyDictionary != null)
|
else if (_readOnlyDictionary != null)
|
||||||
return _readOnlyDictionary;
|
return _readOnlyDictionary;
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ namespace Newtonsoft.Json.Utilities
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if NETFX_CORE
|
#if (NETFX_CORE || PORTABLE)
|
||||||
internal enum TypeCode
|
internal enum TypeCode
|
||||||
{
|
{
|
||||||
Empty,
|
Empty,
|
||||||
@@ -721,18 +721,12 @@ namespace Newtonsoft.Json.Utilities
|
|||||||
return (attributes != null) ? attributes.SingleOrDefault() : null;
|
return (attributes != null) ? attributes.SingleOrDefault() : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !(NETFX_CORE)
|
#if !(NETFX_CORE || PORTABLE)
|
||||||
public static T[] GetAttributes<T>(ICustomAttributeProvider attributeProvider, bool inherit) where T : Attribute
|
public static T[] GetAttributes<T>(ICustomAttributeProvider attributeProvider, bool inherit) where T : Attribute
|
||||||
{
|
{
|
||||||
ValidationUtils.ArgumentNotNull(attributeProvider, "attributeProvider");
|
ValidationUtils.ArgumentNotNull(attributeProvider, "attributeProvider");
|
||||||
|
|
||||||
object provider;
|
object provider = attributeProvider;
|
||||||
|
|
||||||
#if !PORTABLE
|
|
||||||
provider = attributeProvider;
|
|
||||||
#else
|
|
||||||
provider = attributeProvider.UnderlyingObject;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// http://hyperthink.net/blog/getcustomattributes-gotcha/
|
// http://hyperthink.net/blog/getcustomattributes-gotcha/
|
||||||
// ICustomAttributeProvider doesn't do inheritance
|
// ICustomAttributeProvider doesn't do inheritance
|
||||||
@@ -746,19 +740,13 @@ namespace Newtonsoft.Json.Utilities
|
|||||||
if (provider is MemberInfo)
|
if (provider is MemberInfo)
|
||||||
return (T[])Attribute.GetCustomAttributes((MemberInfo)provider, typeof(T), inherit);
|
return (T[])Attribute.GetCustomAttributes((MemberInfo)provider, typeof(T), inherit);
|
||||||
|
|
||||||
#if !PORTABLE
|
|
||||||
if (provider is Module)
|
if (provider is Module)
|
||||||
return (T[])Attribute.GetCustomAttributes((Module)provider, typeof(T), inherit);
|
return (T[])Attribute.GetCustomAttributes((Module)provider, typeof(T), inherit);
|
||||||
#endif
|
|
||||||
|
|
||||||
if (provider is ParameterInfo)
|
if (provider is ParameterInfo)
|
||||||
return (T[])Attribute.GetCustomAttributes((ParameterInfo)provider, typeof(T), inherit);
|
return (T[])Attribute.GetCustomAttributes((ParameterInfo)provider, typeof(T), inherit);
|
||||||
|
|
||||||
#if !PORTABLE
|
|
||||||
return (T[])attributeProvider.GetCustomAttributes(typeof(T), inherit);
|
return (T[])attributeProvider.GetCustomAttributes(typeof(T), inherit);
|
||||||
#else
|
|
||||||
throw new Exception("Cannot get attributes from '{0}'.".FormatWith(CultureInfo.InvariantCulture, provider));
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
public static T[] GetAttributes<T>(ICustomAttributeProvider attributeProvider, bool inherit) where T : Attribute
|
public static T[] GetAttributes<T>(ICustomAttributeProvider attributeProvider, bool inherit) where T : Attribute
|
||||||
@@ -886,7 +874,7 @@ namespace Newtonsoft.Json.Utilities
|
|||||||
ValidationUtils.ArgumentNotNull(targetType, "targetType");
|
ValidationUtils.ArgumentNotNull(targetType, "targetType");
|
||||||
|
|
||||||
List<MemberInfo> fieldInfos = new List<MemberInfo>(targetType.GetFields(bindingAttr));
|
List<MemberInfo> fieldInfos = new List<MemberInfo>(targetType.GetFields(bindingAttr));
|
||||||
#if !NETFX_CORE
|
#if !(NETFX_CORE || PORTABLE)
|
||||||
// Type.GetFields doesn't return inherited private fields
|
// Type.GetFields doesn't return inherited private fields
|
||||||
// manually find private fields from base class
|
// manually find private fields from base class
|
||||||
GetChildPrivateFields(fieldInfos, targetType, bindingAttr);
|
GetChildPrivateFields(fieldInfos, targetType, bindingAttr);
|
||||||
@@ -984,10 +972,7 @@ namespace Newtonsoft.Json.Utilities
|
|||||||
info.Name == method &&
|
info.Name == method &&
|
||||||
// check that the method overrides the original on DynamicObjectProxy
|
// check that the method overrides the original on DynamicObjectProxy
|
||||||
info.DeclaringType != methodDeclaringType
|
info.DeclaringType != methodDeclaringType
|
||||||
// todo - find out whether there is a way to do this in winrt
|
|
||||||
#if !NETFX_CORE
|
|
||||||
&& info.GetBaseDefinition().DeclaringType == methodDeclaringType
|
&& info.GetBaseDefinition().DeclaringType == methodDeclaringType
|
||||||
#endif
|
|
||||||
);
|
);
|
||||||
|
|
||||||
return isMethodOverriden;
|
return isMethodOverriden;
|
||||||
|
|||||||
@@ -162,7 +162,7 @@ namespace Newtonsoft.Json.Utilities
|
|||||||
if ((i == 0 || !hasNext) || char.IsUpper(s[i + 1]))
|
if ((i == 0 || !hasNext) || char.IsUpper(s[i + 1]))
|
||||||
{
|
{
|
||||||
char lowerCase;
|
char lowerCase;
|
||||||
#if !NETFX_CORE
|
#if !(NETFX_CORE || PORTABLE)
|
||||||
lowerCase = char.ToLower(s[i], CultureInfo.InvariantCulture);
|
lowerCase = char.ToLower(s[i], CultureInfo.InvariantCulture);
|
||||||
#else
|
#else
|
||||||
lowerCase = char.ToLower(s[i]);
|
lowerCase = char.ToLower(s[i]);
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ namespace Newtonsoft.Json.Utilities
|
|||||||
Dictionary<TKey, TValue> newStore = new Dictionary<TKey, TValue>(_store);
|
Dictionary<TKey, TValue> newStore = new Dictionary<TKey, TValue>(_store);
|
||||||
newStore[key] = value;
|
newStore[key] = value;
|
||||||
|
|
||||||
#if !NETFX_CORE
|
#if !(NETFX_CORE || PORTABLE)
|
||||||
Thread.MemoryBarrier();
|
Thread.MemoryBarrier();
|
||||||
#endif
|
#endif
|
||||||
_store = newStore;
|
_store = newStore;
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ namespace Newtonsoft.Json.Utilities
|
|||||||
{
|
{
|
||||||
internal static class TypeExtensions
|
internal static class TypeExtensions
|
||||||
{
|
{
|
||||||
#if NETFX_CORE
|
#if NETFX_CORE || PORTABLE
|
||||||
private static BindingFlags DefaultFlags = BindingFlags.Public | BindingFlags.Static | BindingFlags.Instance;
|
private static BindingFlags DefaultFlags = BindingFlags.Public | BindingFlags.Static | BindingFlags.Instance;
|
||||||
|
|
||||||
public static MethodInfo GetGetMethod(this PropertyInfo propertyInfo)
|
public static MethodInfo GetGetMethod(this PropertyInfo propertyInfo)
|
||||||
@@ -80,10 +80,10 @@ namespace Newtonsoft.Json.Utilities
|
|||||||
|
|
||||||
public static MethodInfo Method(this Delegate d)
|
public static MethodInfo Method(this Delegate d)
|
||||||
{
|
{
|
||||||
#if NETFX_CORE
|
#if !(NETFX_CORE || PORTABLE)
|
||||||
return d.GetMethodInfo();
|
|
||||||
#else
|
|
||||||
return d.Method;
|
return d.Method;
|
||||||
|
#else
|
||||||
|
return d.GetMethodInfo();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -107,7 +107,7 @@ namespace Newtonsoft.Json.Utilities
|
|||||||
|
|
||||||
public static bool ContainsGenericParameters(this Type type)
|
public static bool ContainsGenericParameters(this Type type)
|
||||||
{
|
{
|
||||||
#if !NETFX_CORE
|
#if !(NETFX_CORE || PORTABLE)
|
||||||
return type.ContainsGenericParameters;
|
return type.ContainsGenericParameters;
|
||||||
#else
|
#else
|
||||||
return type.GetTypeInfo().ContainsGenericParameters;
|
return type.GetTypeInfo().ContainsGenericParameters;
|
||||||
@@ -116,7 +116,7 @@ namespace Newtonsoft.Json.Utilities
|
|||||||
|
|
||||||
public static bool IsInterface(this Type type)
|
public static bool IsInterface(this Type type)
|
||||||
{
|
{
|
||||||
#if !NETFX_CORE
|
#if !(NETFX_CORE || PORTABLE)
|
||||||
return type.IsInterface;
|
return type.IsInterface;
|
||||||
#else
|
#else
|
||||||
return type.GetTypeInfo().IsInterface;
|
return type.GetTypeInfo().IsInterface;
|
||||||
@@ -125,7 +125,7 @@ namespace Newtonsoft.Json.Utilities
|
|||||||
|
|
||||||
public static bool IsGenericType(this Type type)
|
public static bool IsGenericType(this Type type)
|
||||||
{
|
{
|
||||||
#if !NETFX_CORE
|
#if !(NETFX_CORE || PORTABLE)
|
||||||
return type.IsGenericType;
|
return type.IsGenericType;
|
||||||
#else
|
#else
|
||||||
return type.GetTypeInfo().IsGenericType;
|
return type.GetTypeInfo().IsGenericType;
|
||||||
@@ -134,7 +134,7 @@ namespace Newtonsoft.Json.Utilities
|
|||||||
|
|
||||||
public static bool IsGenericTypeDefinition(this Type type)
|
public static bool IsGenericTypeDefinition(this Type type)
|
||||||
{
|
{
|
||||||
#if !NETFX_CORE
|
#if !(NETFX_CORE || PORTABLE)
|
||||||
return type.IsGenericTypeDefinition;
|
return type.IsGenericTypeDefinition;
|
||||||
#else
|
#else
|
||||||
return type.GetTypeInfo().IsGenericTypeDefinition;
|
return type.GetTypeInfo().IsGenericTypeDefinition;
|
||||||
@@ -143,7 +143,7 @@ namespace Newtonsoft.Json.Utilities
|
|||||||
|
|
||||||
public static Type BaseType(this Type type)
|
public static Type BaseType(this Type type)
|
||||||
{
|
{
|
||||||
#if !NETFX_CORE
|
#if !(NETFX_CORE || PORTABLE)
|
||||||
return type.BaseType;
|
return type.BaseType;
|
||||||
#else
|
#else
|
||||||
return type.GetTypeInfo().BaseType;
|
return type.GetTypeInfo().BaseType;
|
||||||
@@ -152,7 +152,7 @@ namespace Newtonsoft.Json.Utilities
|
|||||||
|
|
||||||
public static bool IsEnum(this Type type)
|
public static bool IsEnum(this Type type)
|
||||||
{
|
{
|
||||||
#if !NETFX_CORE
|
#if !(NETFX_CORE || PORTABLE)
|
||||||
return type.IsEnum;
|
return type.IsEnum;
|
||||||
#else
|
#else
|
||||||
return type.GetTypeInfo().IsEnum;
|
return type.GetTypeInfo().IsEnum;
|
||||||
@@ -161,7 +161,7 @@ namespace Newtonsoft.Json.Utilities
|
|||||||
|
|
||||||
public static bool IsClass(this Type type)
|
public static bool IsClass(this Type type)
|
||||||
{
|
{
|
||||||
#if !NETFX_CORE
|
#if !(NETFX_CORE || PORTABLE)
|
||||||
return type.IsClass;
|
return type.IsClass;
|
||||||
#else
|
#else
|
||||||
return type.GetTypeInfo().IsClass;
|
return type.GetTypeInfo().IsClass;
|
||||||
@@ -170,49 +170,21 @@ namespace Newtonsoft.Json.Utilities
|
|||||||
|
|
||||||
public static bool IsSealed(this Type type)
|
public static bool IsSealed(this Type type)
|
||||||
{
|
{
|
||||||
#if !NETFX_CORE
|
#if !(NETFX_CORE || PORTABLE)
|
||||||
return type.IsSealed;
|
return type.IsSealed;
|
||||||
#else
|
#else
|
||||||
return type.GetTypeInfo().IsSealed;
|
return type.GetTypeInfo().IsSealed;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#if PORTABLE
|
#if (NETFX_CORE || PORTABLE)
|
||||||
public static PropertyInfo GetProperty(this Type type, string name, BindingFlags bindingFlags, object placeholder1, Type propertyType, IList<Type> indexParameters, object placeholder2)
|
public static MethodInfo GetBaseDefinition(this MethodInfo method)
|
||||||
{
|
{
|
||||||
IList<PropertyInfo> propertyInfos = type.GetProperties(bindingFlags);
|
return method.GetRuntimeBaseDefinition();
|
||||||
|
|
||||||
return propertyInfos.Where(p =>
|
|
||||||
{
|
|
||||||
if (name != null && name != p.Name)
|
|
||||||
return false;
|
|
||||||
if (propertyType != null && propertyType != p.PropertyType)
|
|
||||||
return false;
|
|
||||||
if (indexParameters != null)
|
|
||||||
{
|
|
||||||
if (!p.GetIndexParameters().Select(ip => ip.ParameterType).SequenceEqual(indexParameters))
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}).SingleOrDefault();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static IEnumerable<MemberInfo> GetMember(this Type type, string name, MemberTypes memberType, BindingFlags bindingFlags)
|
|
||||||
{
|
|
||||||
return type.GetMembers(bindingFlags).Where(m =>
|
|
||||||
{
|
|
||||||
if (name != null && name != m.Name)
|
|
||||||
return false;
|
|
||||||
if (m.MemberType() != memberType)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if NETFX_CORE
|
#if (NETFX_CORE || PORTABLE)
|
||||||
public static bool IsDefined(this Type type, Type attributeType, bool inherit)
|
public static bool IsDefined(this Type type, Type attributeType, bool inherit)
|
||||||
{
|
{
|
||||||
return type.GetTypeInfo().CustomAttributes.Any(a => a.AttributeType == attributeType);
|
return type.GetTypeInfo().CustomAttributes.Any(a => a.AttributeType == attributeType);
|
||||||
@@ -489,7 +461,7 @@ namespace Newtonsoft.Json.Utilities
|
|||||||
|
|
||||||
public static bool IsAbstract(this Type type)
|
public static bool IsAbstract(this Type type)
|
||||||
{
|
{
|
||||||
#if !NETFX_CORE
|
#if !(NETFX_CORE || PORTABLE)
|
||||||
return type.IsAbstract;
|
return type.IsAbstract;
|
||||||
#else
|
#else
|
||||||
return type.GetTypeInfo().IsAbstract;
|
return type.GetTypeInfo().IsAbstract;
|
||||||
@@ -498,7 +470,7 @@ namespace Newtonsoft.Json.Utilities
|
|||||||
|
|
||||||
public static bool IsVisible(this Type type)
|
public static bool IsVisible(this Type type)
|
||||||
{
|
{
|
||||||
#if !NETFX_CORE
|
#if !(NETFX_CORE || PORTABLE)
|
||||||
return type.IsVisible;
|
return type.IsVisible;
|
||||||
#else
|
#else
|
||||||
return type.GetTypeInfo().IsVisible;
|
return type.GetTypeInfo().IsVisible;
|
||||||
@@ -507,7 +479,7 @@ namespace Newtonsoft.Json.Utilities
|
|||||||
|
|
||||||
public static bool IsValueType(this Type type)
|
public static bool IsValueType(this Type type)
|
||||||
{
|
{
|
||||||
#if !NETFX_CORE
|
#if !(NETFX_CORE || PORTABLE)
|
||||||
return type.IsValueType;
|
return type.IsValueType;
|
||||||
#else
|
#else
|
||||||
return type.GetTypeInfo().IsValueType;
|
return type.GetTypeInfo().IsValueType;
|
||||||
|
|||||||
Reference in New Issue
Block a user