diff options
author | JamesNK <james@newtonking.com> | 2011-01-03 08:19:57 +0300 |
---|---|---|
committer | JamesNK <james@newtonking.com> | 2011-01-03 08:19:57 +0300 |
commit | a96f4d42481b55db2e97516fa7103a90d450ee14 (patch) | |
tree | c97382ca0040bfe9b03b06a4f33694e64838b21e | |
parent | 1aa3ff31a144d757d8a6efbbd110f949e4755c76 (diff) |
-Upgraded Silverlight project to Silverlight 4
-Included .NET 4 features in Silverlight project
18 files changed, 134 insertions, 51 deletions
diff --git a/Build/build.ps1 b/Build/build.ps1 index 04769f7..1f0cdfa 100644 --- a/Build/build.ps1 +++ b/Build/build.ps1 @@ -16,7 +16,7 @@ $builds = @(
@{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.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.Net20"; TestsName = "Newtonsoft.Json.Tests.Net20"; Constants="NET20"; FinalDir="Net20"; NuGetDir = "20"; Framework="net-2.0"}
)
diff --git a/Src/Newtonsoft.Json.Tests/Linq/DynamicTests.cs b/Src/Newtonsoft.Json.Tests/Linq/DynamicTests.cs index e592243..629d6e8 100644 --- a/Src/Newtonsoft.Json.Tests/Linq/DynamicTests.cs +++ b/Src/Newtonsoft.Json.Tests/Linq/DynamicTests.cs @@ -1,6 +1,7 @@ -#if !(NET35 || NET20 || SILVERLIGHT)
+#if !(NET35 || NET20)
using System;
using System.Collections.Generic;
+using System.Dynamic;
using System.Linq;
using System.Text;
using Newtonsoft.Json.Linq;
@@ -177,6 +178,74 @@ namespace Newtonsoft.Json.Tests.Linq T t = d;
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
\ No newline at end of file diff --git a/Src/Newtonsoft.Json.Tests/Newtonsoft.Json.Tests.Silverlight.csproj b/Src/Newtonsoft.Json.Tests/Newtonsoft.Json.Tests.Silverlight.csproj index b0a6688..325ae31 100644 --- a/Src/Newtonsoft.Json.Tests/Newtonsoft.Json.Tests.Silverlight.csproj +++ b/Src/Newtonsoft.Json.Tests/Newtonsoft.Json.Tests.Silverlight.csproj @@ -14,7 +14,7 @@ <AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Newtonsoft.Json.Tests.Silverlight</RootNamespace>
<AssemblyName>Newtonsoft.Json.Tests.Silverlight</AssemblyName>
- <TargetFrameworkVersion>v3.0</TargetFrameworkVersion>
+ <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<SilverlightApplication>false</SilverlightApplication>
<FileUpgradeFlags>
</FileUpgradeFlags>
@@ -65,9 +65,16 @@ <CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<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">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\Lib\NUnit\Silverlight\nunit.framework.dll</HintPath>
+ <Private>True</Private>
+ </Reference>
+ <Reference Include="System.Net">
+ <Private>True</Private>
</Reference>
<Reference Include="System.Runtime.Serialization">
<Private>True</Private>
@@ -106,6 +113,7 @@ <Compile Include="JsonArrayAttributeTests.cs" />
<Compile Include="Linq\ComponentModel\BindingTests.cs" />
<Compile Include="Linq\ComponentModel\JPropertyDescriptorTests.cs" />
+ <Compile Include="Linq\DynamicTests.cs" />
<Compile Include="Linq\JPathTests.cs" />
<Compile Include="Linq\JRawTests.cs" />
<Compile Include="Linq\JTokenReaderTest.cs" />
@@ -116,6 +124,7 @@ <Compile Include="Schema\JsonSchemaNodeTests.cs" />
<Compile Include="Serialization\CamelCasePropertyNamesContractResolverTests.cs" />
<Compile Include="Serialization\ConstructorHandlingTests.cs" />
+ <Compile Include="Serialization\DynamicTests.cs" />
<Compile Include="Serialization\EntitiesSerializationTests.cs" />
<Compile Include="Serialization\JsonSerializerTest.cs" />
<Compile Include="Serialization\MissingMemberHandlingTests.cs" />
@@ -243,6 +252,7 @@ <ProjectReference Include="..\Newtonsoft.Json\Newtonsoft.Json.Silverlight.csproj">
<Project>{DC3C6F3D-2CA1-4278-9B79-63770FB3EA2D}</Project>
<Name>Newtonsoft.Json.Silverlight</Name>
+ <Private>True</Private>
</ProjectReference>
</ItemGroup>
<ItemGroup>
diff --git a/Src/Newtonsoft.Json.Tests/Serialization/DynamicTests.cs b/Src/Newtonsoft.Json.Tests/Serialization/DynamicTests.cs index 7268ddd..fd3c1f8 100644 --- a/Src/Newtonsoft.Json.Tests/Serialization/DynamicTests.cs +++ b/Src/Newtonsoft.Json.Tests/Serialization/DynamicTests.cs @@ -1,4 +1,4 @@ -#if !(NET35 || NET20 || SILVERLIGHT)
+#if !(NET35 || NET20)
using System;
using System.Collections;
using System.Collections.Generic;
@@ -147,15 +147,17 @@ namespace Newtonsoft.Json.Tests.Serialization string json = JsonConvert.SerializeObject(o, Formatting.Indented, new JsonSerializerSettings
{
- TypeNameHandling = TypeNameHandling.All
+ TypeNameHandling = TypeNameHandling.All,
+ TypeNameAssemblyFormat = FormatterAssemblyStyle.Full
});
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(@"{
- ""$type"": ""System.Dynamic.ExpandoObject, System.Core"",
+ ""$type"": """ + expandoObjectTypeName + @""",
""Text"": ""Text!"",
""Integer"": 2147483647,
""DynamicChildObject"": {
@@ -167,7 +169,8 @@ namespace Newtonsoft.Json.Tests.Serialization dynamic n = JsonConvert.DeserializeObject(json, null, new JsonSerializerSettings
{
- TypeNameHandling = TypeNameHandling.All
+ TypeNameHandling = TypeNameHandling.All,
+ TypeNameAssemblyFormat = FormatterAssemblyStyle.Full
});
Assert.IsInstanceOfType(typeof(ExpandoObject), n);
diff --git a/Src/Newtonsoft.Json.Tests/Serialization/JsonSerializerTest.cs b/Src/Newtonsoft.Json.Tests/Serialization/JsonSerializerTest.cs index b0918f1..e31d98a 100644 --- a/Src/Newtonsoft.Json.Tests/Serialization/JsonSerializerTest.cs +++ b/Src/Newtonsoft.Json.Tests/Serialization/JsonSerializerTest.cs @@ -55,7 +55,7 @@ using System.Text.RegularExpressions; using System.Collections.Specialized;
using System.Linq.Expressions;
#endif
-#if !(NET35 || NET20 || SILVERLIGHT)
+#if !(NET35 || NET20 || WINDOWS_PHONE)
using System.Dynamic;
#endif
@@ -3753,7 +3753,7 @@ keyword such as type of business."" }", json);
}
-#if !(NET35 || NET20 || SILVERLIGHT)
+#if !(NET35 || NET20 || WINDOWS_PHONE)
[Test]
public void SerializeExpandoObject()
{
diff --git a/Src/Newtonsoft.Json.Tests/Serialization/SerializationErrorHandlingTests.cs b/Src/Newtonsoft.Json.Tests/Serialization/SerializationErrorHandlingTests.cs index e6af2f8..70f1494 100644 --- a/Src/Newtonsoft.Json.Tests/Serialization/SerializationErrorHandlingTests.cs +++ b/Src/Newtonsoft.Json.Tests/Serialization/SerializationErrorHandlingTests.cs @@ -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(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]);
#else
Assert.AreEqual("The string was not recognized as a valid DateTime. There is a unknown word starting at index 0.", errors[0]);
diff --git a/Src/Newtonsoft.Json.Tests/SilverlightTests.cs b/Src/Newtonsoft.Json.Tests/SilverlightTests.cs index e1df781..e037eed 100644 --- a/Src/Newtonsoft.Json.Tests/SilverlightTests.cs +++ b/Src/Newtonsoft.Json.Tests/SilverlightTests.cs @@ -13,8 +13,8 @@ namespace Newtonsoft.Json.Tests public void SystemVersion()
{
Assembly systemAssembly = typeof(Uri).Assembly;
- StringAssert.Contains("=2.0.5.0,", systemAssembly.FullName,
- "Check we're testing a Silverlight 2.0 assembly");
+ StringAssert.Contains("=4.0.0.0,", systemAssembly.FullName,
+ "Check we're testing a Silverlight 4.0 assembly");
}
}
#endif
diff --git a/Src/Newtonsoft.Json/Linq/JObject.cs b/Src/Newtonsoft.Json/Linq/JObject.cs index 52741bd..4706645 100644 --- a/Src/Newtonsoft.Json/Linq/JObject.cs +++ b/Src/Newtonsoft.Json/Linq/JObject.cs @@ -27,7 +27,7 @@ using System; using System.Collections.Generic;
using System.Collections.Specialized;
using System.ComponentModel;
-#if !(NET35 || NET20 || SILVERLIGHT)
+#if !(NET35 || NET20 || WINDOWS_PHONE)
using System.Dynamic;
using System.Linq.Expressions;
#endif
@@ -654,7 +654,7 @@ namespace Newtonsoft.Json.Linq #endregion
#endif
-#if !(NET35 || NET20 || SILVERLIGHT)
+#if !(NET35 || NET20 || WINDOWS_PHONE)
/// <summary>
/// Returns the <see cref="T:System.Dynamic.DynamicMetaObject"/> responsible for binding operations performed on this object.
/// </summary>
diff --git a/Src/Newtonsoft.Json/Linq/JToken.cs b/Src/Newtonsoft.Json/Linq/JToken.cs index d48e969..8e63c80 100644 --- a/Src/Newtonsoft.Json/Linq/JToken.cs +++ b/Src/Newtonsoft.Json/Linq/JToken.cs @@ -25,7 +25,7 @@ using System;
using System.Collections.Generic;
-#if !(NET35 || NET20 || SILVERLIGHT)
+#if !(NET35 || NET20 || WINDOWS_PHONE)
using System.Dynamic;
using System.Linq.Expressions;
#endif
@@ -46,7 +46,7 @@ namespace Newtonsoft.Json.Linq #if !SILVERLIGHT
, ICloneable
#endif
-#if !(NET35 || NET20 || SILVERLIGHT)
+#if !(NET35 || NET20 || WINDOWS_PHONE)
, IDynamicMetaObjectProvider
#endif
{
@@ -1276,7 +1276,7 @@ namespace Newtonsoft.Json.Linq return p.Evaluate(this, errorWhenNoMatch);
}
-#if !(NET35 || NET20 || SILVERLIGHT)
+#if !(NET35 || NET20 || WINDOWS_PHONE)
/// <summary>
/// Returns the <see cref="T:System.Dynamic.DynamicMetaObject"/> responsible for binding operations performed on this object.
/// </summary>
diff --git a/Src/Newtonsoft.Json/Linq/JValue.cs b/Src/Newtonsoft.Json/Linq/JValue.cs index e8ad67d..554acd4 100644 --- a/Src/Newtonsoft.Json/Linq/JValue.cs +++ b/Src/Newtonsoft.Json/Linq/JValue.cs @@ -30,7 +30,7 @@ using System.Text; using Newtonsoft.Json.Utilities;
using System.Globalization;
using System.ComponentModel;
-#if !(NET35 || NET20 || SILVERLIGHT)
+#if !(NET35 || NET20 || WINDOWS_PHONE)
using System.Dynamic;
using System.Linq.Expressions;
#endif
@@ -406,7 +406,7 @@ namespace Newtonsoft.Json.Linq return _value.GetHashCode();
}
-#if !(NET35 || NET20 || SILVERLIGHT)
+#if !(NET35 || NET20 || WINDOWS_PHONE)
/// <summary>
/// Returns the <see cref="T:System.Dynamic.DynamicMetaObject"/> responsible for binding operations performed on this object.
/// </summary>
@@ -437,16 +437,7 @@ namespace Newtonsoft.Json.Linq return ReflectionUtils.IsNullable(binder.Type);
}
- Type t = 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);
-
+ result = ConvertUtils.Convert(instance.Value, CultureInfo.InvariantCulture, binder.Type);
return true;
}
}
diff --git a/Src/Newtonsoft.Json/Newtonsoft.Json.Silverlight.csproj b/Src/Newtonsoft.Json/Newtonsoft.Json.Silverlight.csproj index b0dfbe6..3bb79fb 100644 --- a/Src/Newtonsoft.Json/Newtonsoft.Json.Silverlight.csproj +++ b/Src/Newtonsoft.Json/Newtonsoft.Json.Silverlight.csproj @@ -14,7 +14,7 @@ <AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Newtonsoft.Json</RootNamespace>
<AssemblyName>Newtonsoft.Json.Silverlight</AssemblyName>
- <TargetFrameworkVersion>v3.0</TargetFrameworkVersion>
+ <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<SilverlightApplication>false</SilverlightApplication>
<ValidateXaml>true</ValidateXaml>
<ThrowErrorsInValidation>false</ThrowErrorsInValidation>
@@ -191,7 +191,10 @@ <Compile Include="Utilities\ConvertUtils.cs" />
<Compile Include="Utilities\DateTimeUtils.cs" />
<Compile Include="Utilities\DictionaryWrapper.cs" />
+ <Compile Include="Utilities\DynamicProxy.cs" />
+ <Compile Include="Utilities\DynamicProxyMetaObject.cs" />
<Compile Include="Utilities\DynamicReflectionDelegateFactory.cs" />
+ <Compile Include="Utilities\DynamicUtils.cs" />
<Compile Include="Utilities\DynamicWrapper.cs" />
<Compile Include="Utilities\EnumUtils.cs" />
<Compile Include="Utilities\EnumValue.cs" />
diff --git a/Src/Newtonsoft.Json/Serialization/DefaultContractResolver.cs b/Src/Newtonsoft.Json/Serialization/DefaultContractResolver.cs index 141782b..62c6484 100644 --- a/Src/Newtonsoft.Json/Serialization/DefaultContractResolver.cs +++ b/Src/Newtonsoft.Json/Serialization/DefaultContractResolver.cs @@ -27,7 +27,7 @@ using System; using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
-#if !(NET35 || NET20 || SILVERLIGHT)
+#if !(NET35 || NET20 || WINDOWS_PHONE)
using System.Dynamic;
#endif
using System.Globalization;
@@ -86,8 +86,10 @@ namespace Newtonsoft.Json.Serialization #endif
new BinaryConverter(),
new KeyValuePairConverter(),
-#if !SILVERLIGHT
+#if !SILVERLIGHT || WINDOWS_PHONE
new XmlNodeConverter(),
+#endif
+#if !SILVERLIGHT
new DataSetConverter(),
new DataTableConverter(),
#endif
@@ -450,7 +452,7 @@ namespace Newtonsoft.Json.Serialization }
#endif
-#if !(NET35 || NET20 || SILVERLIGHT)
+#if !(NET35 || NET20 || WINDOWS_PHONE)
/// <summary>
/// Creates a <see cref="JsonDynamicContract"/> for the given type.
/// </summary>
@@ -515,7 +517,7 @@ namespace Newtonsoft.Json.Serialization return CreateISerializableContract(t);
#endif
-#if !(NET35 || NET20 || SILVERLIGHT)
+#if !(NET35 || NET20 || WINDOWS_PHONE)
if (typeof(IDynamicMetaObjectProvider).IsAssignableFrom(t))
return CreateDynamicContract(t);
#endif
diff --git a/Src/Newtonsoft.Json/Serialization/JsonDynamicContract.cs b/Src/Newtonsoft.Json/Serialization/JsonDynamicContract.cs index ade8c8a..007579e 100644 --- a/Src/Newtonsoft.Json/Serialization/JsonDynamicContract.cs +++ b/Src/Newtonsoft.Json/Serialization/JsonDynamicContract.cs @@ -23,7 +23,7 @@ // OTHER DEALINGS IN THE SOFTWARE.
#endregion
-#if !(NET35 || NET20 || SILVERLIGHT)
+#if !(NET35 || NET20 || WINDOWS_PHONE)
using System;
using System.Collections.Generic;
using System.Reflection;
diff --git a/Src/Newtonsoft.Json/Serialization/JsonSerializerInternalReader.cs b/Src/Newtonsoft.Json/Serialization/JsonSerializerInternalReader.cs index 8ca3954..0d2b083 100644 --- a/Src/Newtonsoft.Json/Serialization/JsonSerializerInternalReader.cs +++ b/Src/Newtonsoft.Json/Serialization/JsonSerializerInternalReader.cs @@ -27,7 +27,7 @@ using System; using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
-#if !(NET35 || NET20 || SILVERLIGHT)
+#if !(NET35 || NET20 || WINDOWS_PHONE)
using System.Dynamic;
#endif
using System.Globalization;
@@ -406,7 +406,7 @@ namespace Newtonsoft.Json.Serialization }
#endif
-#if !(NET35 || NET20 || SILVERLIGHT)
+#if !(NET35 || NET20 || WINDOWS_PHONE)
JsonDynamicContract dynamicContract = contract as JsonDynamicContract;
if (dynamicContract != null)
{
@@ -456,7 +456,11 @@ namespace Newtonsoft.Json.Serialization 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)
@@ -762,7 +766,7 @@ namespace Newtonsoft.Json.Serialization }
#endif
-#if !(NET35 || NET20 || SILVERLIGHT)
+#if !(NET35 || NET20 || WINDOWS_PHONE)
private object CreateDynamic(JsonReader reader, JsonDynamicContract contract, string id)
{
IDynamicMetaObjectProvider newObject = null;
@@ -799,9 +803,9 @@ namespace Newtonsoft.Json.Serialization }
else
{
- object value = (JsonReader.IsPrimitiveToken(reader.TokenType))
- ? reader.Value
- : CreateObject(reader, typeof(IDynamicMetaObjectProvider), GetContractSafe(typeof(IDynamicMetaObjectProvider), null), null, null);
+ Type t = (JsonReader.IsPrimitiveToken(reader.TokenType)) ? reader.ValueType : typeof (IDynamicMetaObjectProvider);
+
+ object value = CreateValueNonProperty(reader, t, GetContractSafe(t, null));
newObject.TrySetMember(memberName, value);
}
diff --git a/Src/Newtonsoft.Json/Serialization/JsonSerializerInternalWriter.cs b/Src/Newtonsoft.Json/Serialization/JsonSerializerInternalWriter.cs index c9ee699..706e17a 100644 --- a/Src/Newtonsoft.Json/Serialization/JsonSerializerInternalWriter.cs +++ b/Src/Newtonsoft.Json/Serialization/JsonSerializerInternalWriter.cs @@ -27,7 +27,7 @@ using System; using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
-#if !(NET35 || NET20 || SILVERLIGHT)
+#if !(NET35 || NET20 || WINDOWS_PHONE)
using System.Dynamic;
#endif
using System.Globalization;
@@ -136,7 +136,7 @@ namespace Newtonsoft.Json.Serialization SerializeISerializable(writer, (ISerializable)value, (JsonISerializableContract)valueContract);
}
#endif
-#if !(NET35 || NET20 || SILVERLIGHT)
+#if !(NET35 || NET20 || WINDOWS_PHONE)
else if (valueContract is JsonDynamicContract)
{
SerializeDynamic(writer, (IDynamicMetaObjectProvider)value, (JsonDynamicContract)valueContract);
@@ -474,7 +474,7 @@ namespace Newtonsoft.Json.Serialization }
#endif
-#if !(NET35 || NET20 || SILVERLIGHT)
+#if !(NET35 || NET20 || WINDOWS_PHONE)
private void SerializeDynamic(JsonWriter writer, IDynamicMetaObjectProvider value, JsonDynamicContract contract)
{
contract.InvokeOnSerializing(value, Serializer.Context);
diff --git a/Src/Newtonsoft.Json/Utilities/DynamicProxy.cs b/Src/Newtonsoft.Json/Utilities/DynamicProxy.cs index 9133bd0..441866a 100644 --- a/Src/Newtonsoft.Json/Utilities/DynamicProxy.cs +++ b/Src/Newtonsoft.Json/Utilities/DynamicProxy.cs @@ -1,4 +1,4 @@ -#if !(NET35 || NET20 || SILVERLIGHT)
+#if !(NET35 || NET20 || WINDOWS_PHONE)
using System;
using System.Collections.Generic;
using System.Dynamic;
diff --git a/Src/Newtonsoft.Json/Utilities/DynamicProxyMetaObject.cs b/Src/Newtonsoft.Json/Utilities/DynamicProxyMetaObject.cs index 9811198..347474a 100644 --- a/Src/Newtonsoft.Json/Utilities/DynamicProxyMetaObject.cs +++ b/Src/Newtonsoft.Json/Utilities/DynamicProxyMetaObject.cs @@ -1,4 +1,4 @@ -#if !(NET35 || NET20 || SILVERLIGHT)
+#if !(NET35 || NET20 || WINDOWS_PHONE)
using System;
using System.Collections.Generic;
using System.Dynamic;
diff --git a/Src/Newtonsoft.Json/Utilities/DynamicUtils.cs b/Src/Newtonsoft.Json/Utilities/DynamicUtils.cs index 75b9ac3..92e338e 100644 --- a/Src/Newtonsoft.Json/Utilities/DynamicUtils.cs +++ b/Src/Newtonsoft.Json/Utilities/DynamicUtils.cs @@ -1,4 +1,4 @@ -#if !(NET35 || NET20 || SILVERLIGHT)
+#if !(NET35 || NET20 || WINDOWS_PHONE)
using System;
using System.Collections.Generic;
using System.Dynamic;
@@ -8,6 +8,7 @@ using System.Reflection; using System.Runtime.CompilerServices;
using System.Text;
using System.Globalization;
+using Newtonsoft.Json.Serialization;
namespace Newtonsoft.Json.Utilities
{
@@ -70,10 +71,10 @@ namespace Newtonsoft.Json.Utilities Type csharpArgumentInfoTypeEnumerableType = typeof(IEnumerable<>).MakeGenericType(csharpArgumentInfoType);
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);
- _setMemberCall = DynamicReflectionDelegateFactory.Instance.CreateMethodCall<object>(setMemberMethod);
+ _setMemberCall = JsonTypeReflector.ReflectionDelegateFactory.CreateMethodCall<object>(setMemberMethod);
}
public static CallSiteBinder GetMember(string name, Type context)
|