-Upgraded Silverlight project to Silverlight 4
-Included .NET 4 features in Silverlight project
This commit is contained in:
+1
-1
@@ -16,7 +16,7 @@
|
|||||||
$builds = @(
|
$builds = @(
|
||||||
@{Name = "Newtonsoft.Json"; TestsName = "Newtonsoft.Json.Tests"; Constants=""; FinalDir="Net"; NuGetDir = "40"; Framework="net-4.0"},
|
@{Name = "Newtonsoft.Json"; TestsName = "Newtonsoft.Json.Tests"; Constants=""; FinalDir="Net"; NuGetDir = "40"; Framework="net-4.0"},
|
||||||
@{Name = "Newtonsoft.Json.WindowsPhone"; TestsName = $null; Constants="SILVERLIGHT;WINDOWS_PHONE"; FinalDir="WindowsPhone"; NuGetDir = "WP"; Framework="net-4.0"},
|
@{Name = "Newtonsoft.Json.WindowsPhone"; TestsName = $null; Constants="SILVERLIGHT;WINDOWS_PHONE"; FinalDir="WindowsPhone"; NuGetDir = "WP"; Framework="net-4.0"},
|
||||||
@{Name = "Newtonsoft.Json.Silverlight"; TestsName = "Newtonsoft.Json.Tests.Silverlight"; Constants="SILVERLIGHT"; FinalDir="Silverlight"; NuGetDir = "SL"; Framework="net-2.0"},
|
@{Name = "Newtonsoft.Json.Silverlight"; TestsName = "Newtonsoft.Json.Tests.Silverlight"; Constants="SILVERLIGHT"; FinalDir="Silverlight"; NuGetDir = "SL"; Framework="net-4.0"},
|
||||||
@{Name = "Newtonsoft.Json.Net35"; TestsName = "Newtonsoft.Json.Tests.Net35"; Constants="NET35"; FinalDir="Net35"; NuGetDir = "35"; Framework="net-2.0"},
|
@{Name = "Newtonsoft.Json.Net35"; TestsName = "Newtonsoft.Json.Tests.Net35"; Constants="NET35"; FinalDir="Net35"; NuGetDir = "35"; Framework="net-2.0"},
|
||||||
@{Name = "Newtonsoft.Json.Net20"; TestsName = "Newtonsoft.Json.Tests.Net20"; Constants="NET20"; FinalDir="Net20"; NuGetDir = "20"; Framework="net-2.0"}
|
@{Name = "Newtonsoft.Json.Net20"; TestsName = "Newtonsoft.Json.Tests.Net20"; Constants="NET20"; FinalDir="Net20"; NuGetDir = "20"; Framework="net-2.0"}
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#if !(NET35 || NET20 || SILVERLIGHT)
|
#if !(NET35 || NET20)
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Dynamic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
@@ -177,6 +178,74 @@ namespace Newtonsoft.Json.Tests.Linq
|
|||||||
T t = d;
|
T t = d;
|
||||||
Assert.AreEqual(value, t);
|
Assert.AreEqual(value, t);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void DynamicSerializerExample()
|
||||||
|
{
|
||||||
|
dynamic value = new DynamicDictionary();
|
||||||
|
|
||||||
|
value.Name = "Arine Admin";
|
||||||
|
value.Enabled = true;
|
||||||
|
value.Roles = new[] {"Admin", "User"};
|
||||||
|
|
||||||
|
string json = JsonConvert.SerializeObject(value, Formatting.Indented);
|
||||||
|
// {
|
||||||
|
// "Name": "Arine Admin",
|
||||||
|
// "Enabled": true,
|
||||||
|
// "Roles": [
|
||||||
|
// "Admin",
|
||||||
|
// "User"
|
||||||
|
// ]
|
||||||
|
// }
|
||||||
|
|
||||||
|
dynamic newValue = JsonConvert.DeserializeObject<DynamicDictionary>(json);
|
||||||
|
|
||||||
|
string role = newValue.Roles[0];
|
||||||
|
// Admin
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void DynamicLinqExample()
|
||||||
|
{
|
||||||
|
JObject oldAndBusted = new JObject();
|
||||||
|
oldAndBusted["Name"] = "Arnie Admin";
|
||||||
|
oldAndBusted["Enabled"] = true;
|
||||||
|
oldAndBusted["Roles"] = new JArray(new[] { "Admin", "User" });
|
||||||
|
|
||||||
|
string oldRole = (string) oldAndBusted["Roles"][0];
|
||||||
|
// Admin
|
||||||
|
|
||||||
|
|
||||||
|
dynamic newHotness = new JObject();
|
||||||
|
newHotness.Name = "Arnie Admin";
|
||||||
|
newHotness.Enabled = true;
|
||||||
|
newHotness.Roles = new JArray(new[] { "Admin", "User" });
|
||||||
|
|
||||||
|
string newRole = newHotness.Roles[0];
|
||||||
|
// Admin
|
||||||
|
}
|
||||||
|
|
||||||
|
public class DynamicDictionary : DynamicObject
|
||||||
|
{
|
||||||
|
private readonly IDictionary<string, object> _values = new Dictionary<string, object>();
|
||||||
|
|
||||||
|
public override IEnumerable<string> GetDynamicMemberNames()
|
||||||
|
{
|
||||||
|
return _values.Keys;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool TryGetMember(GetMemberBinder binder, out object result)
|
||||||
|
{
|
||||||
|
result = _values[binder.Name];
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool TrySetMember(SetMemberBinder binder, object value)
|
||||||
|
{
|
||||||
|
_values[binder.Name] = value;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -14,7 +14,7 @@
|
|||||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||||
<RootNamespace>Newtonsoft.Json.Tests.Silverlight</RootNamespace>
|
<RootNamespace>Newtonsoft.Json.Tests.Silverlight</RootNamespace>
|
||||||
<AssemblyName>Newtonsoft.Json.Tests.Silverlight</AssemblyName>
|
<AssemblyName>Newtonsoft.Json.Tests.Silverlight</AssemblyName>
|
||||||
<TargetFrameworkVersion>v3.0</TargetFrameworkVersion>
|
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||||
<SilverlightApplication>false</SilverlightApplication>
|
<SilverlightApplication>false</SilverlightApplication>
|
||||||
<FileUpgradeFlags>
|
<FileUpgradeFlags>
|
||||||
</FileUpgradeFlags>
|
</FileUpgradeFlags>
|
||||||
@@ -65,9 +65,16 @@
|
|||||||
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
|
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Reference Include="Microsoft.CSharp, Version=2.0.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||||
|
<Private>True</Private>
|
||||||
|
</Reference>
|
||||||
<Reference Include="nunit.framework, Version=2.4.7.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
|
<Reference Include="nunit.framework, Version=2.4.7.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
|
||||||
<SpecificVersion>False</SpecificVersion>
|
<SpecificVersion>False</SpecificVersion>
|
||||||
<HintPath>..\Lib\NUnit\Silverlight\nunit.framework.dll</HintPath>
|
<HintPath>..\Lib\NUnit\Silverlight\nunit.framework.dll</HintPath>
|
||||||
|
<Private>True</Private>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Net">
|
||||||
|
<Private>True</Private>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="System.Runtime.Serialization">
|
<Reference Include="System.Runtime.Serialization">
|
||||||
<Private>True</Private>
|
<Private>True</Private>
|
||||||
@@ -106,6 +113,7 @@
|
|||||||
<Compile Include="JsonArrayAttributeTests.cs" />
|
<Compile Include="JsonArrayAttributeTests.cs" />
|
||||||
<Compile Include="Linq\ComponentModel\BindingTests.cs" />
|
<Compile Include="Linq\ComponentModel\BindingTests.cs" />
|
||||||
<Compile Include="Linq\ComponentModel\JPropertyDescriptorTests.cs" />
|
<Compile Include="Linq\ComponentModel\JPropertyDescriptorTests.cs" />
|
||||||
|
<Compile Include="Linq\DynamicTests.cs" />
|
||||||
<Compile Include="Linq\JPathTests.cs" />
|
<Compile Include="Linq\JPathTests.cs" />
|
||||||
<Compile Include="Linq\JRawTests.cs" />
|
<Compile Include="Linq\JRawTests.cs" />
|
||||||
<Compile Include="Linq\JTokenReaderTest.cs" />
|
<Compile Include="Linq\JTokenReaderTest.cs" />
|
||||||
@@ -116,6 +124,7 @@
|
|||||||
<Compile Include="Schema\JsonSchemaNodeTests.cs" />
|
<Compile Include="Schema\JsonSchemaNodeTests.cs" />
|
||||||
<Compile Include="Serialization\CamelCasePropertyNamesContractResolverTests.cs" />
|
<Compile Include="Serialization\CamelCasePropertyNamesContractResolverTests.cs" />
|
||||||
<Compile Include="Serialization\ConstructorHandlingTests.cs" />
|
<Compile Include="Serialization\ConstructorHandlingTests.cs" />
|
||||||
|
<Compile Include="Serialization\DynamicTests.cs" />
|
||||||
<Compile Include="Serialization\EntitiesSerializationTests.cs" />
|
<Compile Include="Serialization\EntitiesSerializationTests.cs" />
|
||||||
<Compile Include="Serialization\JsonSerializerTest.cs" />
|
<Compile Include="Serialization\JsonSerializerTest.cs" />
|
||||||
<Compile Include="Serialization\MissingMemberHandlingTests.cs" />
|
<Compile Include="Serialization\MissingMemberHandlingTests.cs" />
|
||||||
@@ -243,6 +252,7 @@
|
|||||||
<ProjectReference Include="..\Newtonsoft.Json\Newtonsoft.Json.Silverlight.csproj">
|
<ProjectReference Include="..\Newtonsoft.Json\Newtonsoft.Json.Silverlight.csproj">
|
||||||
<Project>{DC3C6F3D-2CA1-4278-9B79-63770FB3EA2D}</Project>
|
<Project>{DC3C6F3D-2CA1-4278-9B79-63770FB3EA2D}</Project>
|
||||||
<Name>Newtonsoft.Json.Silverlight</Name>
|
<Name>Newtonsoft.Json.Silverlight</Name>
|
||||||
|
<Private>True</Private>
|
||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#if !(NET35 || NET20 || SILVERLIGHT)
|
#if !(NET35 || NET20)
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@@ -147,15 +147,17 @@ namespace Newtonsoft.Json.Tests.Serialization
|
|||||||
|
|
||||||
string json = JsonConvert.SerializeObject(o, Formatting.Indented, new JsonSerializerSettings
|
string json = JsonConvert.SerializeObject(o, Formatting.Indented, new JsonSerializerSettings
|
||||||
{
|
{
|
||||||
TypeNameHandling = TypeNameHandling.All
|
TypeNameHandling = TypeNameHandling.All,
|
||||||
|
TypeNameAssemblyFormat = FormatterAssemblyStyle.Full
|
||||||
});
|
});
|
||||||
|
|
||||||
Console.WriteLine(json);
|
Console.WriteLine(json);
|
||||||
|
|
||||||
string dynamicChildObjectTypeName = ReflectionUtils.GetTypeName(typeof(DynamicChildObject), FormatterAssemblyStyle.Simple);
|
string dynamicChildObjectTypeName = ReflectionUtils.GetTypeName(typeof(DynamicChildObject), FormatterAssemblyStyle.Full);
|
||||||
|
string expandoObjectTypeName = ReflectionUtils.GetTypeName(typeof(ExpandoObject), FormatterAssemblyStyle.Full);
|
||||||
|
|
||||||
Assert.AreEqual(@"{
|
Assert.AreEqual(@"{
|
||||||
""$type"": ""System.Dynamic.ExpandoObject, System.Core"",
|
""$type"": """ + expandoObjectTypeName + @""",
|
||||||
""Text"": ""Text!"",
|
""Text"": ""Text!"",
|
||||||
""Integer"": 2147483647,
|
""Integer"": 2147483647,
|
||||||
""DynamicChildObject"": {
|
""DynamicChildObject"": {
|
||||||
@@ -167,7 +169,8 @@ namespace Newtonsoft.Json.Tests.Serialization
|
|||||||
|
|
||||||
dynamic n = JsonConvert.DeserializeObject(json, null, new JsonSerializerSettings
|
dynamic n = JsonConvert.DeserializeObject(json, null, new JsonSerializerSettings
|
||||||
{
|
{
|
||||||
TypeNameHandling = TypeNameHandling.All
|
TypeNameHandling = TypeNameHandling.All,
|
||||||
|
TypeNameAssemblyFormat = FormatterAssemblyStyle.Full
|
||||||
});
|
});
|
||||||
|
|
||||||
Assert.IsInstanceOfType(typeof(ExpandoObject), n);
|
Assert.IsInstanceOfType(typeof(ExpandoObject), n);
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ using System.Text.RegularExpressions;
|
|||||||
using System.Collections.Specialized;
|
using System.Collections.Specialized;
|
||||||
using System.Linq.Expressions;
|
using System.Linq.Expressions;
|
||||||
#endif
|
#endif
|
||||||
#if !(NET35 || NET20 || SILVERLIGHT)
|
#if !(NET35 || NET20 || WINDOWS_PHONE)
|
||||||
using System.Dynamic;
|
using System.Dynamic;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -3753,7 +3753,7 @@ keyword such as type of business.""
|
|||||||
}", json);
|
}", json);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !(NET35 || NET20 || SILVERLIGHT)
|
#if !(NET35 || NET20 || WINDOWS_PHONE)
|
||||||
[Test]
|
[Test]
|
||||||
public void SerializeExpandoObject()
|
public void SerializeExpandoObject()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -195,7 +195,7 @@ namespace Newtonsoft.Json.Tests.Serialization
|
|||||||
Assert.AreEqual(new DateTime(2000, 12, 1, 0, 0, 0, DateTimeKind.Utc), c[2]);
|
Assert.AreEqual(new DateTime(2000, 12, 1, 0, 0, 0, DateTimeKind.Utc), c[2]);
|
||||||
|
|
||||||
Assert.AreEqual(3, errors.Count);
|
Assert.AreEqual(3, errors.Count);
|
||||||
#if !(NET20 || NET35 || SILVERLIGHT)
|
#if !(NET20 || NET35 || WINDOWS_PHONE)
|
||||||
Assert.AreEqual("The string was not recognized as a valid DateTime. There is an unknown word starting at index 0.", errors[0]);
|
Assert.AreEqual("The string was not recognized as a valid DateTime. There is an unknown word starting at index 0.", errors[0]);
|
||||||
#else
|
#else
|
||||||
Assert.AreEqual("The string was not recognized as a valid DateTime. There is a unknown word starting at index 0.", errors[0]);
|
Assert.AreEqual("The string was not recognized as a valid DateTime. There is a unknown word starting at index 0.", errors[0]);
|
||||||
|
|||||||
@@ -13,8 +13,8 @@ namespace Newtonsoft.Json.Tests
|
|||||||
public void SystemVersion()
|
public void SystemVersion()
|
||||||
{
|
{
|
||||||
Assembly systemAssembly = typeof(Uri).Assembly;
|
Assembly systemAssembly = typeof(Uri).Assembly;
|
||||||
StringAssert.Contains("=2.0.5.0,", systemAssembly.FullName,
|
StringAssert.Contains("=4.0.0.0,", systemAssembly.FullName,
|
||||||
"Check we're testing a Silverlight 2.0 assembly");
|
"Check we're testing a Silverlight 4.0 assembly");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Collections.Specialized;
|
using System.Collections.Specialized;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
#if !(NET35 || NET20 || SILVERLIGHT)
|
#if !(NET35 || NET20 || WINDOWS_PHONE)
|
||||||
using System.Dynamic;
|
using System.Dynamic;
|
||||||
using System.Linq.Expressions;
|
using System.Linq.Expressions;
|
||||||
#endif
|
#endif
|
||||||
@@ -654,7 +654,7 @@ namespace Newtonsoft.Json.Linq
|
|||||||
#endregion
|
#endregion
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !(NET35 || NET20 || SILVERLIGHT)
|
#if !(NET35 || NET20 || WINDOWS_PHONE)
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns the <see cref="T:System.Dynamic.DynamicMetaObject"/> responsible for binding operations performed on this object.
|
/// Returns the <see cref="T:System.Dynamic.DynamicMetaObject"/> responsible for binding operations performed on this object.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
#if !(NET35 || NET20 || SILVERLIGHT)
|
#if !(NET35 || NET20 || WINDOWS_PHONE)
|
||||||
using System.Dynamic;
|
using System.Dynamic;
|
||||||
using System.Linq.Expressions;
|
using System.Linq.Expressions;
|
||||||
#endif
|
#endif
|
||||||
@@ -46,7 +46,7 @@ namespace Newtonsoft.Json.Linq
|
|||||||
#if !SILVERLIGHT
|
#if !SILVERLIGHT
|
||||||
, ICloneable
|
, ICloneable
|
||||||
#endif
|
#endif
|
||||||
#if !(NET35 || NET20 || SILVERLIGHT)
|
#if !(NET35 || NET20 || WINDOWS_PHONE)
|
||||||
, IDynamicMetaObjectProvider
|
, IDynamicMetaObjectProvider
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
@@ -1276,7 +1276,7 @@ namespace Newtonsoft.Json.Linq
|
|||||||
return p.Evaluate(this, errorWhenNoMatch);
|
return p.Evaluate(this, errorWhenNoMatch);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !(NET35 || NET20 || SILVERLIGHT)
|
#if !(NET35 || NET20 || WINDOWS_PHONE)
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns the <see cref="T:System.Dynamic.DynamicMetaObject"/> responsible for binding operations performed on this object.
|
/// Returns the <see cref="T:System.Dynamic.DynamicMetaObject"/> responsible for binding operations performed on this object.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ using System.Text;
|
|||||||
using Newtonsoft.Json.Utilities;
|
using Newtonsoft.Json.Utilities;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
#if !(NET35 || NET20 || SILVERLIGHT)
|
#if !(NET35 || NET20 || WINDOWS_PHONE)
|
||||||
using System.Dynamic;
|
using System.Dynamic;
|
||||||
using System.Linq.Expressions;
|
using System.Linq.Expressions;
|
||||||
#endif
|
#endif
|
||||||
@@ -406,7 +406,7 @@ namespace Newtonsoft.Json.Linq
|
|||||||
return _value.GetHashCode();
|
return _value.GetHashCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !(NET35 || NET20 || SILVERLIGHT)
|
#if !(NET35 || NET20 || WINDOWS_PHONE)
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns the <see cref="T:System.Dynamic.DynamicMetaObject"/> responsible for binding operations performed on this object.
|
/// Returns the <see cref="T:System.Dynamic.DynamicMetaObject"/> responsible for binding operations performed on this object.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -437,16 +437,7 @@ namespace Newtonsoft.Json.Linq
|
|||||||
return ReflectionUtils.IsNullable(binder.Type);
|
return ReflectionUtils.IsNullable(binder.Type);
|
||||||
}
|
}
|
||||||
|
|
||||||
Type t = binder.Type;
|
result = ConvertUtils.Convert(instance.Value, CultureInfo.InvariantCulture, binder.Type);
|
||||||
if (ReflectionUtils.IsNullableType(t))
|
|
||||||
t = Nullable.GetUnderlyingType(t);
|
|
||||||
|
|
||||||
TypeConverter converter = TypeDescriptor.GetConverter(instance.Value);
|
|
||||||
if (converter != null && converter.CanConvertTo(t))
|
|
||||||
result = converter.ConvertTo(instance.Value, t);
|
|
||||||
else
|
|
||||||
result = Convert.ChangeType(instance.Value, t, CultureInfo.InvariantCulture);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||||
<RootNamespace>Newtonsoft.Json</RootNamespace>
|
<RootNamespace>Newtonsoft.Json</RootNamespace>
|
||||||
<AssemblyName>Newtonsoft.Json.Silverlight</AssemblyName>
|
<AssemblyName>Newtonsoft.Json.Silverlight</AssemblyName>
|
||||||
<TargetFrameworkVersion>v3.0</TargetFrameworkVersion>
|
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||||
<SilverlightApplication>false</SilverlightApplication>
|
<SilverlightApplication>false</SilverlightApplication>
|
||||||
<ValidateXaml>true</ValidateXaml>
|
<ValidateXaml>true</ValidateXaml>
|
||||||
<ThrowErrorsInValidation>false</ThrowErrorsInValidation>
|
<ThrowErrorsInValidation>false</ThrowErrorsInValidation>
|
||||||
@@ -191,7 +191,10 @@
|
|||||||
<Compile Include="Utilities\ConvertUtils.cs" />
|
<Compile Include="Utilities\ConvertUtils.cs" />
|
||||||
<Compile Include="Utilities\DateTimeUtils.cs" />
|
<Compile Include="Utilities\DateTimeUtils.cs" />
|
||||||
<Compile Include="Utilities\DictionaryWrapper.cs" />
|
<Compile Include="Utilities\DictionaryWrapper.cs" />
|
||||||
|
<Compile Include="Utilities\DynamicProxy.cs" />
|
||||||
|
<Compile Include="Utilities\DynamicProxyMetaObject.cs" />
|
||||||
<Compile Include="Utilities\DynamicReflectionDelegateFactory.cs" />
|
<Compile Include="Utilities\DynamicReflectionDelegateFactory.cs" />
|
||||||
|
<Compile Include="Utilities\DynamicUtils.cs" />
|
||||||
<Compile Include="Utilities\DynamicWrapper.cs" />
|
<Compile Include="Utilities\DynamicWrapper.cs" />
|
||||||
<Compile Include="Utilities\EnumUtils.cs" />
|
<Compile Include="Utilities\EnumUtils.cs" />
|
||||||
<Compile Include="Utilities\EnumValue.cs" />
|
<Compile Include="Utilities\EnumValue.cs" />
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ using System;
|
|||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
#if !(NET35 || NET20 || SILVERLIGHT)
|
#if !(NET35 || NET20 || WINDOWS_PHONE)
|
||||||
using System.Dynamic;
|
using System.Dynamic;
|
||||||
#endif
|
#endif
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
@@ -86,8 +86,10 @@ namespace Newtonsoft.Json.Serialization
|
|||||||
#endif
|
#endif
|
||||||
new BinaryConverter(),
|
new BinaryConverter(),
|
||||||
new KeyValuePairConverter(),
|
new KeyValuePairConverter(),
|
||||||
#if !SILVERLIGHT
|
#if !SILVERLIGHT || WINDOWS_PHONE
|
||||||
new XmlNodeConverter(),
|
new XmlNodeConverter(),
|
||||||
|
#endif
|
||||||
|
#if !SILVERLIGHT
|
||||||
new DataSetConverter(),
|
new DataSetConverter(),
|
||||||
new DataTableConverter(),
|
new DataTableConverter(),
|
||||||
#endif
|
#endif
|
||||||
@@ -450,7 +452,7 @@ namespace Newtonsoft.Json.Serialization
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !(NET35 || NET20 || SILVERLIGHT)
|
#if !(NET35 || NET20 || WINDOWS_PHONE)
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a <see cref="JsonDynamicContract"/> for the given type.
|
/// Creates a <see cref="JsonDynamicContract"/> for the given type.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -515,7 +517,7 @@ namespace Newtonsoft.Json.Serialization
|
|||||||
return CreateISerializableContract(t);
|
return CreateISerializableContract(t);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !(NET35 || NET20 || SILVERLIGHT)
|
#if !(NET35 || NET20 || WINDOWS_PHONE)
|
||||||
if (typeof(IDynamicMetaObjectProvider).IsAssignableFrom(t))
|
if (typeof(IDynamicMetaObjectProvider).IsAssignableFrom(t))
|
||||||
return CreateDynamicContract(t);
|
return CreateDynamicContract(t);
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -23,7 +23,7 @@
|
|||||||
// OTHER DEALINGS IN THE SOFTWARE.
|
// OTHER DEALINGS IN THE SOFTWARE.
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#if !(NET35 || NET20 || SILVERLIGHT)
|
#if !(NET35 || NET20 || WINDOWS_PHONE)
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ using System;
|
|||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
#if !(NET35 || NET20 || SILVERLIGHT)
|
#if !(NET35 || NET20 || WINDOWS_PHONE)
|
||||||
using System.Dynamic;
|
using System.Dynamic;
|
||||||
#endif
|
#endif
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
@@ -406,7 +406,7 @@ namespace Newtonsoft.Json.Serialization
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !(NET35 || NET20 || SILVERLIGHT)
|
#if !(NET35 || NET20 || WINDOWS_PHONE)
|
||||||
JsonDynamicContract dynamicContract = contract as JsonDynamicContract;
|
JsonDynamicContract dynamicContract = contract as JsonDynamicContract;
|
||||||
if (dynamicContract != null)
|
if (dynamicContract != null)
|
||||||
{
|
{
|
||||||
@@ -456,7 +456,11 @@ namespace Newtonsoft.Json.Serialization
|
|||||||
|
|
||||||
private bool HasDefinedType(Type type)
|
private bool HasDefinedType(Type type)
|
||||||
{
|
{
|
||||||
return (type != null && type != typeof (object) && !type.IsSubclassOf(typeof(JToken)));
|
return (type != null && type != typeof (object) && !typeof(JToken).IsAssignableFrom(type)
|
||||||
|
#if !(NET35 || NET20 || WINDOWS_PHONE)
|
||||||
|
&& type != typeof(IDynamicMetaObjectProvider)
|
||||||
|
#endif
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private object EnsureType(object value, Type targetType)
|
private object EnsureType(object value, Type targetType)
|
||||||
@@ -762,7 +766,7 @@ namespace Newtonsoft.Json.Serialization
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !(NET35 || NET20 || SILVERLIGHT)
|
#if !(NET35 || NET20 || WINDOWS_PHONE)
|
||||||
private object CreateDynamic(JsonReader reader, JsonDynamicContract contract, string id)
|
private object CreateDynamic(JsonReader reader, JsonDynamicContract contract, string id)
|
||||||
{
|
{
|
||||||
IDynamicMetaObjectProvider newObject = null;
|
IDynamicMetaObjectProvider newObject = null;
|
||||||
@@ -799,9 +803,9 @@ namespace Newtonsoft.Json.Serialization
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
object value = (JsonReader.IsPrimitiveToken(reader.TokenType))
|
Type t = (JsonReader.IsPrimitiveToken(reader.TokenType)) ? reader.ValueType : typeof (IDynamicMetaObjectProvider);
|
||||||
? reader.Value
|
|
||||||
: CreateObject(reader, typeof(IDynamicMetaObjectProvider), GetContractSafe(typeof(IDynamicMetaObjectProvider), null), null, null);
|
object value = CreateValueNonProperty(reader, t, GetContractSafe(t, null));
|
||||||
|
|
||||||
newObject.TrySetMember(memberName, value);
|
newObject.TrySetMember(memberName, value);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ using System;
|
|||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
#if !(NET35 || NET20 || SILVERLIGHT)
|
#if !(NET35 || NET20 || WINDOWS_PHONE)
|
||||||
using System.Dynamic;
|
using System.Dynamic;
|
||||||
#endif
|
#endif
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
@@ -136,7 +136,7 @@ namespace Newtonsoft.Json.Serialization
|
|||||||
SerializeISerializable(writer, (ISerializable)value, (JsonISerializableContract)valueContract);
|
SerializeISerializable(writer, (ISerializable)value, (JsonISerializableContract)valueContract);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#if !(NET35 || NET20 || SILVERLIGHT)
|
#if !(NET35 || NET20 || WINDOWS_PHONE)
|
||||||
else if (valueContract is JsonDynamicContract)
|
else if (valueContract is JsonDynamicContract)
|
||||||
{
|
{
|
||||||
SerializeDynamic(writer, (IDynamicMetaObjectProvider)value, (JsonDynamicContract)valueContract);
|
SerializeDynamic(writer, (IDynamicMetaObjectProvider)value, (JsonDynamicContract)valueContract);
|
||||||
@@ -474,7 +474,7 @@ namespace Newtonsoft.Json.Serialization
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !(NET35 || NET20 || SILVERLIGHT)
|
#if !(NET35 || NET20 || WINDOWS_PHONE)
|
||||||
private void SerializeDynamic(JsonWriter writer, IDynamicMetaObjectProvider value, JsonDynamicContract contract)
|
private void SerializeDynamic(JsonWriter writer, IDynamicMetaObjectProvider value, JsonDynamicContract contract)
|
||||||
{
|
{
|
||||||
contract.InvokeOnSerializing(value, Serializer.Context);
|
contract.InvokeOnSerializing(value, Serializer.Context);
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#if !(NET35 || NET20 || SILVERLIGHT)
|
#if !(NET35 || NET20 || WINDOWS_PHONE)
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Dynamic;
|
using System.Dynamic;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#if !(NET35 || NET20 || SILVERLIGHT)
|
#if !(NET35 || NET20 || WINDOWS_PHONE)
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Dynamic;
|
using System.Dynamic;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#if !(NET35 || NET20 || SILVERLIGHT)
|
#if !(NET35 || NET20 || WINDOWS_PHONE)
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Dynamic;
|
using System.Dynamic;
|
||||||
@@ -8,6 +8,7 @@ using System.Reflection;
|
|||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
|
using Newtonsoft.Json.Serialization;
|
||||||
|
|
||||||
namespace Newtonsoft.Json.Utilities
|
namespace Newtonsoft.Json.Utilities
|
||||||
{
|
{
|
||||||
@@ -70,10 +71,10 @@ namespace Newtonsoft.Json.Utilities
|
|||||||
Type csharpArgumentInfoTypeEnumerableType = typeof(IEnumerable<>).MakeGenericType(csharpArgumentInfoType);
|
Type csharpArgumentInfoTypeEnumerableType = typeof(IEnumerable<>).MakeGenericType(csharpArgumentInfoType);
|
||||||
|
|
||||||
MethodInfo getMemberMethod = binderType.GetMethod("GetMember", BindingFlags.Public | BindingFlags.Static, null, new[] { csharpBinderFlagsType, typeof(string), typeof(Type), csharpArgumentInfoTypeEnumerableType }, null);
|
MethodInfo getMemberMethod = binderType.GetMethod("GetMember", BindingFlags.Public | BindingFlags.Static, null, new[] { csharpBinderFlagsType, typeof(string), typeof(Type), csharpArgumentInfoTypeEnumerableType }, null);
|
||||||
_getMemberCall = DynamicReflectionDelegateFactory.Instance.CreateMethodCall<object>(getMemberMethod);
|
_getMemberCall = JsonTypeReflector.ReflectionDelegateFactory.CreateMethodCall<object>(getMemberMethod);
|
||||||
|
|
||||||
MethodInfo setMemberMethod = binderType.GetMethod("SetMember", BindingFlags.Public | BindingFlags.Static, null, new[] { csharpBinderFlagsType, typeof(string), typeof(Type), csharpArgumentInfoTypeEnumerableType }, null);
|
MethodInfo setMemberMethod = binderType.GetMethod("SetMember", BindingFlags.Public | BindingFlags.Static, null, new[] { csharpBinderFlagsType, typeof(string), typeof(Type), csharpArgumentInfoTypeEnumerableType }, null);
|
||||||
_setMemberCall = DynamicReflectionDelegateFactory.Instance.CreateMethodCall<object>(setMemberMethod);
|
_setMemberCall = JsonTypeReflector.ReflectionDelegateFactory.CreateMethodCall<object>(setMemberMethod);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static CallSiteBinder GetMember(string name, Type context)
|
public static CallSiteBinder GetMember(string name, Type context)
|
||||||
|
|||||||
Reference in New Issue
Block a user