-Removed old PocketPC ifdefs

This commit is contained in:
James Newton-King
2013-02-10 17:49:36 +13:00
parent b71e17cc42
commit c6eff351a4
47 changed files with 82 additions and 145 deletions
@@ -82,7 +82,7 @@ namespace Newtonsoft.Json.Tests.Bson
Assert.AreEqual("0F-00-00-00-10-42-6C-61-68-00-01-00-00-00-00", bson); Assert.AreEqual("0F-00-00-00-10-42-6C-61-68-00-01-00-00-00-00", bson);
} }
#if !PocketPC && !NET20 #if !NET20
[Test] [Test]
public void WriteValues() public void WriteValues()
{ {
@@ -25,7 +25,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
#if !SILVERLIGHT && !PocketPC && !NET20 && !NETFX_CORE #if !SILVERLIGHT && !NET20 && !NETFX_CORE
using System.Data.Linq; using System.Data.Linq;
#endif #endif
#if !(SILVERLIGHT || NETFX_CORE) #if !(SILVERLIGHT || NETFX_CORE)
@@ -27,7 +27,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
#if !SILVERLIGHT && !PocketPC && !NET20 && !NETFX_CORE #if !SILVERLIGHT && !NET20 && !NETFX_CORE
using System.Data.Linq; using System.Data.Linq;
#endif #endif
#if !SILVERLIGHT && !NETFX_CORE #if !SILVERLIGHT && !NETFX_CORE
@@ -149,7 +149,7 @@ namespace Newtonsoft.Json.Tests.Converters
} }
#endif #endif
#if !PocketPC && !NET20 #if !NET20
[Test] [Test]
public void SerializeDateTimeOffset() public void SerializeDateTimeOffset()
{ {
@@ -53,7 +53,7 @@ namespace Newtonsoft.Json.Tests.Converters
Assert.AreEqual("new Date(976918263055)", result); Assert.AreEqual("new Date(976918263055)", result);
} }
#if !PocketPC && !NET20 #if !NET20
[Test] [Test]
public void SerializeDateTimeOffset() public void SerializeDateTimeOffset()
{ {
@@ -25,7 +25,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
#if !SILVERLIGHT && !PocketPC && !NET20 && !NETFX_CORE #if !SILVERLIGHT && !NET20 && !NETFX_CORE
using System.Data.Linq; using System.Data.Linq;
#endif #endif
#if !SILVERLIGHT && !NETFX_CORE #if !SILVERLIGHT && !NETFX_CORE
+2 -2
View File
@@ -231,7 +231,7 @@ now brown cow?", '"', true);
value = new DateTime(JsonConvert.InitialJavaScriptDateTicks, DateTimeKind.Utc); value = new DateTime(JsonConvert.InitialJavaScriptDateTicks, DateTimeKind.Utc);
Assert.AreEqual(@"""\/Date(0)\/""", JsonConvert.ToString((DateTime)value, DateFormatHandling.MicrosoftDateFormat, DateTimeZoneHandling.RoundtripKind)); Assert.AreEqual(@"""\/Date(0)\/""", JsonConvert.ToString((DateTime)value, DateFormatHandling.MicrosoftDateFormat, DateTimeZoneHandling.RoundtripKind));
#if !PocketPC && !NET20 #if !NET20
value = new DateTimeOffset(JsonConvert.InitialJavaScriptDateTicks, TimeSpan.Zero); value = new DateTimeOffset(JsonConvert.InitialJavaScriptDateTicks, TimeSpan.Zero);
Assert.AreEqual(@"""1970-01-01T00:00:00+00:00""", JsonConvert.ToString(value)); Assert.AreEqual(@"""1970-01-01T00:00:00+00:00""", JsonConvert.ToString(value));
@@ -280,7 +280,7 @@ now brown cow?", '"', true);
int i = JsonConvert.DeserializeObject<int>("1"); int i = JsonConvert.DeserializeObject<int>("1");
Assert.AreEqual(1, i); Assert.AreEqual(1, i);
#if !PocketPC && !NET20 #if !NET20
DateTimeOffset d = JsonConvert.DeserializeObject<DateTimeOffset>(@"""\/Date(-59011455539000+0000)\/"""); DateTimeOffset d = JsonConvert.DeserializeObject<DateTimeOffset>(@"""\/Date(-59011455539000+0000)\/""");
Assert.AreEqual(new DateTimeOffset(new DateTime(100, 1, 1, 1, 1, 1, DateTimeKind.Utc)), d); Assert.AreEqual(new DateTimeOffset(new DateTime(100, 1, 1, 1, 1, 1, DateTimeKind.Utc)), d);
#endif #endif
@@ -133,7 +133,7 @@ namespace Newtonsoft.Json.Tests
jsonWriter.WriteValue((decimal?)1.1m); jsonWriter.WriteValue((decimal?)1.1m);
jsonWriter.WriteValue((DateTime?)null); jsonWriter.WriteValue((DateTime?)null);
jsonWriter.WriteValue((DateTime?)new DateTime(JsonConvert.InitialJavaScriptDateTicks, DateTimeKind.Utc)); jsonWriter.WriteValue((DateTime?)new DateTime(JsonConvert.InitialJavaScriptDateTicks, DateTimeKind.Utc));
#if !PocketPC && !NET20 #if !NET20
jsonWriter.WriteValue((DateTimeOffset?)null); jsonWriter.WriteValue((DateTimeOffset?)null);
jsonWriter.WriteValue((DateTimeOffset?)new DateTimeOffset(JsonConvert.InitialJavaScriptDateTicks, TimeSpan.Zero)); jsonWriter.WriteValue((DateTimeOffset?)new DateTimeOffset(JsonConvert.InitialJavaScriptDateTicks, TimeSpan.Zero));
#endif #endif
@@ -143,7 +143,7 @@ namespace Newtonsoft.Json.Tests
string json = sw.ToString(); string json = sw.ToString();
string expected; string expected;
#if !PocketPC && !NET20 #if !NET20
expected = @"[null,""c"",null,true,null,1,null,1,null,1,null,1,null,1,null,1,null,1,null,1,null,1.1,null,1.1,null,1.1,null,""1970-01-01T00:00:00Z"",null,""1970-01-01T00:00:00+00:00""]"; expected = @"[null,""c"",null,true,null,1,null,1,null,1,null,1,null,1,null,1,null,1,null,1,null,1.1,null,1.1,null,1.1,null,""1970-01-01T00:00:00Z"",null,""1970-01-01T00:00:00+00:00""]";
#else #else
expected = @"[null,""c"",null,true,null,1,null,1,null,1,null,1,null,1,null,1,null,1,null,1,null,1.1,null,1.1,null,1.1,null,""1970-01-01T00:00:00Z""]"; expected = @"[null,""c"",null,true,null,1,null,1,null,1,null,1,null,1,null,1,null,1,null,1,null,1.1,null,1.1,null,1.1,null,""1970-01-01T00:00:00Z""]";
@@ -38,7 +38,7 @@ using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAtt
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
using System.IO; using System.IO;
using System.Collections; using System.Collections;
#if !PocketPC && !SILVERLIGHT && !NETFX_CORE #if !SILVERLIGHT && !NETFX_CORE
using System.Web.UI; using System.Web.UI;
#endif #endif
#if NET20 #if NET20
@@ -44,7 +44,7 @@ namespace Newtonsoft.Json.Tests.Linq
[TestFixture] [TestFixture]
public class JTokenReaderTest : TestFixtureBase public class JTokenReaderTest : TestFixtureBase
{ {
#if !PocketPC && !NET20 #if !NET20
[Test] [Test]
public void YahooFinance() public void YahooFinance()
{ {
@@ -233,7 +233,7 @@ namespace Newtonsoft.Json.Tests.Linq
Assert.AreEqual(2L, (long)new JArray(1, 2, 3)[1]); Assert.AreEqual(2L, (long)new JArray(1, 2, 3)[1]);
Assert.AreEqual(new DateTime(2000, 12, 20), (DateTime)new JValue(new DateTime(2000, 12, 20))); Assert.AreEqual(new DateTime(2000, 12, 20), (DateTime)new JValue(new DateTime(2000, 12, 20)));
#if !PocketPC && !NET20 #if !NET20
Assert.AreEqual(new DateTimeOffset(2000, 12, 20, 0, 0, 0, TimeSpan.Zero), (DateTimeOffset)new JValue(new DateTime(2000, 12, 20, 0, 0, 0, DateTimeKind.Utc))); Assert.AreEqual(new DateTimeOffset(2000, 12, 20, 0, 0, 0, TimeSpan.Zero), (DateTimeOffset)new JValue(new DateTime(2000, 12, 20, 0, 0, 0, DateTimeKind.Utc)));
Assert.AreEqual(new DateTimeOffset(2000, 12, 20, 23, 50, 10, TimeSpan.Zero), (DateTimeOffset)new JValue(new DateTimeOffset(2000, 12, 20, 23, 50, 10, TimeSpan.Zero))); Assert.AreEqual(new DateTimeOffset(2000, 12, 20, 23, 50, 10, TimeSpan.Zero), (DateTimeOffset)new JValue(new DateTimeOffset(2000, 12, 20, 23, 50, 10, TimeSpan.Zero)));
Assert.AreEqual(null, (DateTimeOffset?)new JValue((DateTimeOffset?)null)); Assert.AreEqual(null, (DateTimeOffset?)new JValue((DateTimeOffset?)null));
@@ -446,7 +446,7 @@ namespace Newtonsoft.Json.Tests.Linq
public void ImplicitCastingTo() public void ImplicitCastingTo()
{ {
Assert.IsTrue(JToken.DeepEquals(new JValue(new DateTime(2000, 12, 20)), (JValue)new DateTime(2000, 12, 20))); Assert.IsTrue(JToken.DeepEquals(new JValue(new DateTime(2000, 12, 20)), (JValue)new DateTime(2000, 12, 20)));
#if !PocketPC && !NET20 #if !NET20
Assert.IsTrue(JToken.DeepEquals(new JValue(new DateTimeOffset(2000, 12, 20, 23, 50, 10, TimeSpan.Zero)), (JValue)new DateTimeOffset(2000, 12, 20, 23, 50, 10, TimeSpan.Zero))); Assert.IsTrue(JToken.DeepEquals(new JValue(new DateTimeOffset(2000, 12, 20, 23, 50, 10, TimeSpan.Zero)), (JValue)new DateTimeOffset(2000, 12, 20, 23, 50, 10, TimeSpan.Zero)));
Assert.IsTrue(JToken.DeepEquals(new JValue((DateTimeOffset?)null), (JValue)(DateTimeOffset?)null)); Assert.IsTrue(JToken.DeepEquals(new JValue((DateTimeOffset?)null), (JValue)(DateTimeOffset?)null));
#endif #endif
@@ -565,7 +565,7 @@ keyword such as type of business.""
}); });
} }
#if !PocketPC && !NET20 #if !NET20
[Test] [Test]
public void ToStringJsonConverter() public void ToStringJsonConverter()
{ {
@@ -23,7 +23,7 @@
// OTHER DEALINGS IN THE SOFTWARE. // OTHER DEALINGS IN THE SOFTWARE.
#endregion #endregion
#if !(SILVERLIGHT || PocketPC || NET20 || NET35 || NETFX_CORE || PORTABLE) #if !(SILVERLIGHT || NET20 || NET35 || NETFX_CORE || PORTABLE)
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Globalization; using System.Globalization;
@@ -35,8 +35,6 @@ using System.Security;
[assembly: AssemblyTitle("Json.NET Tests Windows Phone")] [assembly: AssemblyTitle("Json.NET Tests Windows Phone")]
#elif SILVERLIGHT #elif SILVERLIGHT
[assembly: AssemblyTitle("Json.NET Tests Silverlight")] [assembly: AssemblyTitle("Json.NET Tests Silverlight")]
#elif PocketPC
[assembly: AssemblyTitle("Json.NET Tests Compact")]
#elif PORTABLE #elif PORTABLE
[assembly: AssemblyTitle("Json.NET Tests Portable")] [assembly: AssemblyTitle("Json.NET Tests Portable")]
#elif NETFX_CORE #elif NETFX_CORE
@@ -75,6 +73,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")]
#if !PocketPC
[assembly: AssemblyFileVersion("4.5.11.15810")] [assembly: AssemblyFileVersion("4.5.11.15810")]
#endif
@@ -199,7 +199,7 @@ namespace Newtonsoft.Json.Tests.Schema
GenerateSchemaAndSerializeFromType(new CircularReferenceWithIdClass()); GenerateSchemaAndSerializeFromType(new CircularReferenceWithIdClass());
GenerateSchemaAndSerializeFromType(new ClassWithArray()); GenerateSchemaAndSerializeFromType(new ClassWithArray());
GenerateSchemaAndSerializeFromType(new ClassWithGuid()); GenerateSchemaAndSerializeFromType(new ClassWithGuid());
#if !NET20 && !PocketPC #if !NET20
GenerateSchemaAndSerializeFromType(new NullableDateTimeTestClass()); GenerateSchemaAndSerializeFromType(new NullableDateTimeTestClass());
#endif #endif
#if !(SILVERLIGHT || NETFX_CORE || PORTABLE) #if !(SILVERLIGHT || NETFX_CORE || PORTABLE)
@@ -27,7 +27,7 @@ using System;
using System.ComponentModel; using System.ComponentModel;
using System.IO; using System.IO;
using System.Runtime.Serialization; using System.Runtime.Serialization;
#if !(SILVERLIGHT || PocketPC || NET20 || NET35 || NETFX_CORE || PORTABLE) #if !(SILVERLIGHT || NET20 || NET35 || NETFX_CORE || PORTABLE)
using System.Runtime.Serialization.Json; using System.Runtime.Serialization.Json;
#endif #endif
using System.Text; using System.Text;
@@ -209,7 +209,7 @@ namespace Newtonsoft.Json.Tests.Serialization
{ {
EmitDefaultValueClass c = new EmitDefaultValueClass(); EmitDefaultValueClass c = new EmitDefaultValueClass();
#if !(SILVERLIGHT || PocketPC || NET20 || NET35 || NETFX_CORE || PORTABLE) #if !(SILVERLIGHT || NET20 || NET35 || NETFX_CORE || PORTABLE)
DataContractJsonSerializer jsonSerializer = new DataContractJsonSerializer(typeof(EmitDefaultValueClass)); DataContractJsonSerializer jsonSerializer = new DataContractJsonSerializer(typeof(EmitDefaultValueClass));
MemoryStream ms = new MemoryStream(); MemoryStream ms = new MemoryStream();
@@ -28,7 +28,7 @@ using System;
using System.Collections.Concurrent; using System.Collections.Concurrent;
#endif #endif
using System.Collections.Generic; using System.Collections.Generic;
#if !SILVERLIGHT && !PocketPC && !NET20 && !NETFX_CORE #if !SILVERLIGHT && !NET20 && !NETFX_CORE
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.Configuration; using System.Configuration;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
@@ -53,7 +53,7 @@ using System.Collections.ObjectModel;
using Newtonsoft.Json.Bson; using Newtonsoft.Json.Bson;
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
using Newtonsoft.Json.Converters; using Newtonsoft.Json.Converters;
#if !PocketPC && !NET20 && !WINDOWS_PHONE #if !NET20 && !WINDOWS_PHONE
using System.Runtime.Serialization.Json; using System.Runtime.Serialization.Json;
#endif #endif
using Newtonsoft.Json.Serialization; using Newtonsoft.Json.Serialization;
@@ -173,7 +173,7 @@ namespace Newtonsoft.Json.Tests.Serialization
string jsonText = JsonConvert.SerializeObject(testDictionary); string jsonText = JsonConvert.SerializeObject(testDictionary);
#if !PocketPC && !NET20 && !WINDOWS_PHONE #if !NET20 && !WINDOWS_PHONE
MemoryStream ms = new MemoryStream(); MemoryStream ms = new MemoryStream();
DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(Dictionary<string, object>)); DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(Dictionary<string, object>));
serializer.WriteObject(ms, testDictionary); serializer.WriteObject(ms, testDictionary);
@@ -432,7 +432,7 @@ keyword such as type of business.""
CollectionAssert.AreEqual(r1, r2); CollectionAssert.AreEqual(r1, r2);
} }
#if !PocketPC && !NET20 && !WINDOWS_PHONE #if !NET20 && !WINDOWS_PHONE
[Test] [Test]
public void Unicode() public void Unicode()
{ {
@@ -1595,7 +1595,7 @@ keyword such as type of business.""
} }
#endif #endif
#if !PocketPC && !NET20 #if !NET20
[DataContract] [DataContract]
public class DataContractPrivateMembers public class DataContractPrivateMembers
{ {
@@ -1982,7 +1982,7 @@ keyword such as type of business.""
Assert.AreEqual("Product 1", products[0].Name); Assert.AreEqual("Product 1", products[0].Name);
} }
#if !PocketPC && !NET20 #if !NET20
[Test] [Test]
public void DeserializeEmptyStringToNullableDateTime() public void DeserializeEmptyStringToNullableDateTime()
{ {
@@ -2759,7 +2759,7 @@ Path '', line 1, position 2.",
public string Ethnicity { get; set; } public string Ethnicity { get; set; }
} }
#if !NET20 && !PocketPC && !WINDOWS_PHONE #if !NET20 && !WINDOWS_PHONE
public class DataContractJsonSerializerTestClass public class DataContractJsonSerializerTestClass
{ {
public TimeSpan TimeSpanProperty { get; set; } public TimeSpan TimeSpanProperty { get; set; }
@@ -4108,7 +4108,7 @@ To fix this error either change the environment to be fully trusted, change the
Assert.AreEqual(null, d[2]); Assert.AreEqual(null, d[2]);
} }
#if !SILVERLIGHT && !NET20 && !PocketPC #if !SILVERLIGHT && !NET20
[Test] [Test]
public void SerializeHashSet() public void SerializeHashSet()
{ {
@@ -4161,7 +4161,7 @@ To fix this error either change the environment to be fully trusted, change the
Assert.AreEqual(0, z[1].Prop1.Length); Assert.AreEqual(0, z[1].Prop1.Length);
} }
#if !NET20 && !PocketPC && !SILVERLIGHT && !NETFX_CORE #if !NET20 && !SILVERLIGHT && !NETFX_CORE
public class StringDictionaryTestClass public class StringDictionaryTestClass
{ {
public StringDictionary StringDictionaryProperty { get; set; } public StringDictionary StringDictionaryProperty { get; set; }
@@ -4456,7 +4456,7 @@ To fix this error either change the environment to be fully trusted, change the
Assert.AreEqual(meh.IDontWork, "meh"); Assert.AreEqual(meh.IDontWork, "meh");
} }
#if !(SILVERLIGHT || PocketPC || NET20 || NETFX_CORE) #if !(SILVERLIGHT || NET20 || NETFX_CORE)
[DataContract] [DataContract]
public struct StructISerializable : ISerializable public struct StructISerializable : ISerializable
{ {
@@ -23,7 +23,6 @@
// OTHER DEALINGS IN THE SOFTWARE. // OTHER DEALINGS IN THE SOFTWARE.
#endregion #endregion
#if !PocketPC
using System; using System;
using System.Diagnostics; using System.Diagnostics;
using System.IO; using System.IO;
@@ -337,4 +336,3 @@ namespace Newtonsoft.Json.Tests.Serialization
} }
} }
} }
#endif
@@ -26,7 +26,7 @@
using System; using System;
using System.Runtime.Serialization; using System.Runtime.Serialization;
#if !PocketPC && !NET20 #if !NET20
namespace Newtonsoft.Json.Tests.TestObjects namespace Newtonsoft.Json.Tests.TestObjects
{ {
[DataContract] [DataContract]
@@ -23,7 +23,7 @@
// OTHER DEALINGS IN THE SOFTWARE. // OTHER DEALINGS IN THE SOFTWARE.
#endregion #endregion
#if !PocketPC && !NET20 #if !NET20
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
@@ -27,7 +27,7 @@ using System.ComponentModel;
namespace Newtonsoft.Json.Tests.TestObjects namespace Newtonsoft.Json.Tests.TestObjects
{ {
#if !PocketPC && !NETFX_CORE #if !NETFX_CORE
[Description("DefaultValueAttributeTestClass description!")] [Description("DefaultValueAttributeTestClass description!")]
#endif #endif
public sealed class DefaultValueAttributeTestClass public sealed class DefaultValueAttributeTestClass
@@ -23,7 +23,7 @@
// OTHER DEALINGS IN THE SOFTWARE. // OTHER DEALINGS IN THE SOFTWARE.
#endregion #endregion
#if !PocketPC && !NET20 #if !NET20
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@@ -29,7 +29,7 @@ using System.ComponentModel;
namespace Newtonsoft.Json.Tests.TestObjects namespace Newtonsoft.Json.Tests.TestObjects
{ {
[JsonObject(Id = "Person", Title = "Title!", Description = "JsonObjectAttribute description!", MemberSerialization = MemberSerialization.OptIn)] [JsonObject(Id = "Person", Title = "Title!", Description = "JsonObjectAttribute description!", MemberSerialization = MemberSerialization.OptIn)]
#if !PocketPC && !NETFX_CORE #if !NETFX_CORE
[Description("DescriptionAttribute description!")] [Description("DescriptionAttribute description!")]
#endif #endif
public class Person public class Person
@@ -23,7 +23,6 @@
// OTHER DEALINGS IN THE SOFTWARE. // OTHER DEALINGS IN THE SOFTWARE.
#endregion #endregion
#if !PocketPC
using System.Collections.Generic; using System.Collections.Generic;
using System.Runtime.Serialization; using System.Runtime.Serialization;
@@ -79,4 +78,3 @@ namespace Newtonsoft.Json.Tests.TestObjects
} }
} }
} }
#endif
@@ -23,7 +23,6 @@
// OTHER DEALINGS IN THE SOFTWARE. // OTHER DEALINGS IN THE SOFTWARE.
#endregion #endregion
#if !PocketPC
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Runtime.Serialization; using System.Runtime.Serialization;
@@ -79,4 +78,3 @@ namespace Newtonsoft.Json.Tests.TestObjects
} }
} }
} }
#endif
@@ -23,7 +23,6 @@
// OTHER DEALINGS IN THE SOFTWARE. // OTHER DEALINGS IN THE SOFTWARE.
#endregion #endregion
#if !PocketPC
using System; using System;
using System.Runtime.Serialization; using System.Runtime.Serialization;
using Newtonsoft.Json.Serialization; using Newtonsoft.Json.Serialization;
@@ -98,4 +97,3 @@ namespace Newtonsoft.Json.Tests.TestObjects
} }
} }
} }
#endif
@@ -23,7 +23,6 @@
// OTHER DEALINGS IN THE SOFTWARE. // OTHER DEALINGS IN THE SOFTWARE.
#endregion #endregion
#if !PocketPC
using System; using System;
using System.Runtime.Serialization; using System.Runtime.Serialization;
using Newtonsoft.Json.Serialization; using Newtonsoft.Json.Serialization;
@@ -82,4 +81,3 @@ namespace Newtonsoft.Json.Tests.TestObjects
} }
} }
} }
#endif
+1 -1
View File
@@ -148,7 +148,7 @@ namespace Newtonsoft.Json.Bson
ticks = JsonConvert.ConvertDateTimeToJavaScriptTicks(dateTime, false); ticks = JsonConvert.ConvertDateTimeToJavaScriptTicks(dateTime, false);
} }
#if !PocketPC && !NET20 #if !NET20
else else
{ {
DateTimeOffset dateTimeOffset = (DateTimeOffset)value.Value; DateTimeOffset dateTimeOffset = (DateTimeOffset)value.Value;
+1 -1
View File
@@ -407,7 +407,7 @@ namespace Newtonsoft.Json.Bson
AddValue(value, BsonType.Date); AddValue(value, BsonType.Date);
} }
#if !PocketPC && !NET20 #if !NET20
/// <summary> /// <summary>
/// Writes a <see cref="DateTimeOffset"/> value. /// Writes a <see cref="DateTimeOffset"/> value.
/// </summary> /// </summary>
@@ -43,7 +43,7 @@ namespace Newtonsoft.Json.Converters
{ {
if (objectType == typeof(DateTime) || objectType == typeof(DateTime?)) if (objectType == typeof(DateTime) || objectType == typeof(DateTime?))
return true; return true;
#if !PocketPC && !NET20 #if !NET20
if (objectType == typeof(DateTimeOffset) || objectType == typeof(DateTimeOffset?)) if (objectType == typeof(DateTimeOffset) || objectType == typeof(DateTimeOffset?))
return true; return true;
#endif #endif
@@ -90,7 +90,7 @@ namespace Newtonsoft.Json.Converters
text = dateTime.ToString(_dateTimeFormat ?? DefaultDateTimeFormat, Culture); text = dateTime.ToString(_dateTimeFormat ?? DefaultDateTimeFormat, Culture);
} }
#if !PocketPC && !NET20 #if !NET20
else if (value is DateTimeOffset) else if (value is DateTimeOffset)
{ {
DateTimeOffset dateTimeOffset = (DateTimeOffset)value; DateTimeOffset dateTimeOffset = (DateTimeOffset)value;
@@ -134,7 +134,7 @@ namespace Newtonsoft.Json.Converters
if (reader.TokenType == JsonToken.Date) if (reader.TokenType == JsonToken.Date)
{ {
#if !PocketPC && !NET20 #if !NET20
if (t == typeof(DateTimeOffset)) if (t == typeof(DateTimeOffset))
return new DateTimeOffset((DateTime)reader.Value); return new DateTimeOffset((DateTime)reader.Value);
#endif #endif
@@ -150,7 +150,7 @@ namespace Newtonsoft.Json.Converters
if (string.IsNullOrEmpty(dateText) && nullable) if (string.IsNullOrEmpty(dateText) && nullable)
return null; return null;
#if !PocketPC && !NET20 #if !NET20
if (t == typeof(DateTimeOffset)) if (t == typeof(DateTimeOffset))
{ {
if (!string.IsNullOrEmpty(_dateTimeFormat)) if (!string.IsNullOrEmpty(_dateTimeFormat))
@@ -50,7 +50,7 @@ namespace Newtonsoft.Json.Converters
DateTime utcDateTime = dateTime.ToUniversalTime(); DateTime utcDateTime = dateTime.ToUniversalTime();
ticks = JsonConvert.ConvertDateTimeToJavaScriptTicks(utcDateTime); ticks = JsonConvert.ConvertDateTimeToJavaScriptTicks(utcDateTime);
} }
#if !PocketPC && !NET20 #if !NET20
else if (value is DateTimeOffset) else if (value is DateTimeOffset)
{ {
DateTimeOffset dateTimeOffset = (DateTimeOffset)value; DateTimeOffset dateTimeOffset = (DateTimeOffset)value;
@@ -107,7 +107,7 @@ namespace Newtonsoft.Json.Converters
if (reader.TokenType != JsonToken.EndConstructor) if (reader.TokenType != JsonToken.EndConstructor)
throw JsonSerializationException.Create(reader, "Unexpected token parsing date. Expected EndConstructor, got {0}.".FormatWith(CultureInfo.InvariantCulture, reader.TokenType)); throw JsonSerializationException.Create(reader, "Unexpected token parsing date. Expected EndConstructor, got {0}.".FormatWith(CultureInfo.InvariantCulture, reader.TokenType));
#if !PocketPC && !NET20 #if !NET20
if (t == typeof(DateTimeOffset)) if (t == typeof(DateTimeOffset))
return new DateTimeOffset(d); return new DateTimeOffset(d);
#endif #endif
+3 -3
View File
@@ -137,7 +137,7 @@ namespace Newtonsoft.Json
return value; return value;
} }
#if !PocketPC && !NET20 #if !NET20
/// <summary> /// <summary>
/// Converts the <see cref="DateTimeOffset"/> to its JSON string representation. /// Converts the <see cref="DateTimeOffset"/> to its JSON string representation.
/// </summary> /// </summary>
@@ -656,7 +656,7 @@ namespace Newtonsoft.Json
#endif #endif
} }
} }
#if !PocketPC && !NET20 #if !NET20
else if (value is DateTimeOffset) else if (value is DateTimeOffset)
{ {
return ToString((DateTimeOffset) value); return ToString((DateTimeOffset) value);
@@ -711,7 +711,7 @@ namespace Newtonsoft.Json
if (ReflectionUtils.IsNullableType(type)) if (ReflectionUtils.IsNullableType(type))
type = Nullable.GetUnderlyingType(type); type = Nullable.GetUnderlyingType(type);
#if !PocketPC && !NET20 #if !NET20
if (type == typeof (DateTimeOffset)) if (type == typeof (DateTimeOffset))
return true; return true;
#endif #endif
+1 -1
View File
@@ -507,7 +507,7 @@ namespace Newtonsoft.Json
} }
} }
#if !PocketPC && !NET20 #if !NET20
/// <summary> /// <summary>
/// Writes a <see cref="DateTimeOffset"/> value. /// Writes a <see cref="DateTimeOffset"/> value.
/// </summary> /// </summary>
+4 -4
View File
@@ -521,7 +521,7 @@ namespace Newtonsoft.Json
WriteEndConstructor(); WriteEndConstructor();
break; break;
case JsonToken.Date: case JsonToken.Date:
#if !PocketPC && !NET20 #if !NET20
if (reader.Value is DateTimeOffset) if (reader.Value is DateTimeOffset)
WriteValue((DateTimeOffset)reader.Value); WriteValue((DateTimeOffset)reader.Value);
else else
@@ -949,7 +949,7 @@ namespace Newtonsoft.Json
InternalWriteValue(JsonToken.Date); InternalWriteValue(JsonToken.Date);
} }
#if !PocketPC && !NET20 #if !NET20
/// <summary> /// <summary>
/// Writes a <see cref="DateTimeOffset"/> value. /// Writes a <see cref="DateTimeOffset"/> value.
/// </summary> /// </summary>
@@ -1150,7 +1150,7 @@ namespace Newtonsoft.Json
WriteValue(value.Value); WriteValue(value.Value);
} }
#if !PocketPC && !NET20 #if !NET20
/// <summary> /// <summary>
/// Writes a <see cref="Nullable{DateTimeOffset}"/> value. /// Writes a <see cref="Nullable{DateTimeOffset}"/> value.
/// </summary> /// </summary>
@@ -1340,7 +1340,7 @@ namespace Newtonsoft.Json
#endif #endif
} }
} }
#if !PocketPC && !NET20 #if !NET20
else if (value is DateTimeOffset) else if (value is DateTimeOffset)
{ {
if (nullable) if (nullable)
+5 -5
View File
@@ -454,7 +454,7 @@ namespace Newtonsoft.Json.Linq
return Convert.ToBoolean(v.Value, CultureInfo.InvariantCulture); return Convert.ToBoolean(v.Value, CultureInfo.InvariantCulture);
} }
#if !PocketPC && !NET20 #if !NET20
/// <summary> /// <summary>
/// Performs an explicit conversion from <see cref="Newtonsoft.Json.Linq.JToken"/> to <see cref="System.DateTimeOffset"/>. /// Performs an explicit conversion from <see cref="Newtonsoft.Json.Linq.JToken"/> to <see cref="System.DateTimeOffset"/>.
/// </summary> /// </summary>
@@ -522,7 +522,7 @@ namespace Newtonsoft.Json.Linq
return (v.Value != null) ? (DateTime?)Convert.ToDateTime(v.Value, CultureInfo.InvariantCulture) : null; return (v.Value != null) ? (DateTime?)Convert.ToDateTime(v.Value, CultureInfo.InvariantCulture) : null;
} }
#if !PocketPC && !NET20 #if !NET20
/// <summary> /// <summary>
/// Performs an explicit conversion from <see cref="Newtonsoft.Json.Linq.JToken"/> to <see cref="Nullable{DateTimeOffset}"/>. /// Performs an explicit conversion from <see cref="Newtonsoft.Json.Linq.JToken"/> to <see cref="Nullable{DateTimeOffset}"/>.
/// </summary> /// </summary>
@@ -1036,7 +1036,7 @@ namespace Newtonsoft.Json.Linq
return new JValue(value); return new JValue(value);
} }
#if !PocketPC && !NET20 #if !NET20
/// <summary> /// <summary>
/// Performs an implicit conversion from <see cref="DateTimeOffset"/> to <see cref="JToken"/>. /// Performs an implicit conversion from <see cref="DateTimeOffset"/> to <see cref="JToken"/>.
/// </summary> /// </summary>
@@ -1078,7 +1078,7 @@ namespace Newtonsoft.Json.Linq
return new JValue(value); return new JValue(value);
} }
#if !PocketPC && !NET20 #if !NET20
/// <summary> /// <summary>
/// Performs an implicit conversion from <see cref="Nullable{DateTimeOffset}"/> to <see cref="JToken"/>. /// Performs an implicit conversion from <see cref="Nullable{DateTimeOffset}"/> to <see cref="JToken"/>.
/// </summary> /// </summary>
@@ -1517,7 +1517,7 @@ namespace Newtonsoft.Json.Linq
return (string) this; return (string) this;
} }
#if !PocketPC && !NET20 #if !NET20
if (objectType == typeof (DateTimeOffset)) if (objectType == typeof (DateTimeOffset))
{ {
if (isNullable) if (isNullable)
+1 -1
View File
@@ -377,7 +377,7 @@ namespace Newtonsoft.Json.Linq
AddValue(value, JsonToken.Date); AddValue(value, JsonToken.Date);
} }
#if !PocketPC && !NET20 #if !NET20
/// <summary> /// <summary>
/// Writes a <see cref="DateTimeOffset"/> value. /// Writes a <see cref="DateTimeOffset"/> value.
/// </summary> /// </summary>
+2 -2
View File
@@ -460,7 +460,7 @@ namespace Newtonsoft.Json.Linq
return JTokenType.Float; return JTokenType.Float;
else if (value is DateTime) else if (value is DateTime)
return JTokenType.Date; return JTokenType.Date;
#if !PocketPC && !NET20 #if !NET20
else if (value is DateTimeOffset) else if (value is DateTimeOffset)
return JTokenType.Date; return JTokenType.Date;
#endif #endif
@@ -573,7 +573,7 @@ namespace Newtonsoft.Json.Linq
writer.WriteValue(Convert.ToBoolean(_value, CultureInfo.InvariantCulture)); writer.WriteValue(Convert.ToBoolean(_value, CultureInfo.InvariantCulture));
return; return;
case JTokenType.Date: case JTokenType.Date:
#if !PocketPC && !NET20 #if !NET20
if (_value is DateTimeOffset) if (_value is DateTimeOffset)
writer.WriteValue((DateTimeOffset)_value); writer.WriteValue((DateTimeOffset)_value);
else else
@@ -36,8 +36,6 @@ using System.Security;
[assembly: AssemblyTitle("Json.NET Windows Phone")] [assembly: AssemblyTitle("Json.NET Windows Phone")]
#elif SILVERLIGHT #elif SILVERLIGHT
[assembly: AssemblyTitle("Json.NET Silverlight")] [assembly: AssemblyTitle("Json.NET Silverlight")]
#elif PocketPC
[assembly: AssemblyTitle("Json.NET Compact")]
#elif PORTABLE #elif PORTABLE
[assembly: AssemblyTitle("Json.NET Portable")] [assembly: AssemblyTitle("Json.NET Portable")]
#elif NETFX_CORE #elif NETFX_CORE
@@ -89,8 +87,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")]
#if !PocketPC
[assembly: AssemblyFileVersion("4.5.11.15810")] [assembly: AssemblyFileVersion("4.5.11.15810")]
#endif
[assembly: CLSCompliant(true)] [assembly: CLSCompliant(true)]
@@ -274,7 +274,7 @@ namespace Newtonsoft.Json.Serialization
if (memberSerialization != MemberSerialization.Fields) if (memberSerialization != MemberSerialization.Fields)
{ {
#if !PocketPC && !NET20 #if !NET20
DataContractAttribute dataContractAttribute = JsonTypeReflector.GetDataContractAttribute(objectType); DataContractAttribute dataContractAttribute = JsonTypeReflector.GetDataContractAttribute(objectType);
#endif #endif
@@ -297,7 +297,7 @@ namespace Newtonsoft.Json.Serialization
// or are a field if serializing just fields // or are a field if serializing just fields
if (JsonTypeReflector.GetAttribute<JsonPropertyAttribute>(member.GetCustomAttributeProvider()) != null) if (JsonTypeReflector.GetAttribute<JsonPropertyAttribute>(member.GetCustomAttributeProvider()) != null)
serializableMembers.Add(member); serializableMembers.Add(member);
#if !PocketPC && !NET20 #if !NET20
else if (dataContractAttribute != null && JsonTypeReflector.GetAttribute<DataMemberAttribute>(member.GetCustomAttributeProvider()) != null) else if (dataContractAttribute != null && JsonTypeReflector.GetAttribute<DataMemberAttribute>(member.GetCustomAttributeProvider()) != null)
serializableMembers.Add(member); serializableMembers.Add(member);
#endif #endif
@@ -307,7 +307,7 @@ namespace Newtonsoft.Json.Serialization
} }
} }
#if !PocketPC && !SILVERLIGHT && !NET20 #if !SILVERLIGHT && !NET20
Type match; Type match;
// don't include EntityKey on entities objects... this is a bit hacky // don't include EntityKey on entities objects... this is a bit hacky
if (objectType.AssignableToTypeName("System.Data.Objects.DataClasses.EntityObject", out match)) if (objectType.AssignableToTypeName("System.Data.Objects.DataClasses.EntityObject", out match))
@@ -328,7 +328,7 @@ namespace Newtonsoft.Json.Serialization
return serializableMembers; return serializableMembers;
} }
#if !PocketPC && !SILVERLIGHT && !NET20 #if !SILVERLIGHT && !NET20
private bool ShouldSerializeEntityMember(MemberInfo memberInfo) private bool ShouldSerializeEntityMember(MemberInfo memberInfo)
{ {
PropertyInfo propertyInfo = memberInfo as PropertyInfo; PropertyInfo propertyInfo = memberInfo as PropertyInfo;
@@ -508,7 +508,7 @@ namespace Newtonsoft.Json.Serialization
return JsonTypeReflector.ReflectionDelegateFactory.CreateDefaultConstructor<object>(createdType); return JsonTypeReflector.ReflectionDelegateFactory.CreateDefaultConstructor<object>(createdType);
} }
#if !PocketPC && !NET20 #if !NET20
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Portability", "CA1903:UseOnlyApiFromTargetedFramework", MessageId = "System.Runtime.Serialization.DataContractAttribute.#get_IsReference()")] [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Portability", "CA1903:UseOnlyApiFromTargetedFramework", MessageId = "System.Runtime.Serialization.DataContractAttribute.#get_IsReference()")]
#endif #endif
private void InitializeContract(JsonContract contract) private void InitializeContract(JsonContract contract)
@@ -518,7 +518,7 @@ namespace Newtonsoft.Json.Serialization
{ {
contract.IsReference = containerAttribute._isReference; contract.IsReference = containerAttribute._isReference;
} }
#if !PocketPC && !NET20 #if !NET20
else else
{ {
DataContractAttribute dataContractAttribute = JsonTypeReflector.GetDataContractAttribute(contract.NonNullableUnderlyingType); DataContractAttribute dataContractAttribute = JsonTypeReflector.GetDataContractAttribute(contract.NonNullableUnderlyingType);
@@ -805,7 +805,7 @@ namespace Newtonsoft.Json.Serialization
if (type == typeof(Type) || type.IsSubclassOf(typeof(Type))) if (type == typeof(Type) || type.IsSubclassOf(typeof(Type)))
return true; return true;
#if SILVERLIGHT || PocketPC #if SILVERLIGHT
if (type == typeof(Guid) || type == typeof(Uri) || type == typeof(TimeSpan)) if (type == typeof(Guid) || type == typeof(Uri) || type == typeof(TimeSpan))
return true; return true;
#endif #endif
@@ -938,7 +938,7 @@ namespace Newtonsoft.Json.Serialization
private void SetPropertySettingsFromAttributes(JsonProperty property, ICustomAttributeProvider attributeProvider, string name, Type declaringType, MemberSerialization memberSerialization, out bool allowNonPublicAccess) private void SetPropertySettingsFromAttributes(JsonProperty property, ICustomAttributeProvider attributeProvider, string name, Type declaringType, MemberSerialization memberSerialization, out bool allowNonPublicAccess)
{ {
#if !PocketPC && !NET20 #if !NET20
DataContractAttribute dataContractAttribute = JsonTypeReflector.GetDataContractAttribute(declaringType); DataContractAttribute dataContractAttribute = JsonTypeReflector.GetDataContractAttribute(declaringType);
MemberInfo memberInfo = null; MemberInfo memberInfo = null;
@@ -962,7 +962,7 @@ namespace Newtonsoft.Json.Serialization
string mappedName; string mappedName;
if (propertyAttribute != null && propertyAttribute.PropertyName != null) if (propertyAttribute != null && propertyAttribute.PropertyName != null)
mappedName = propertyAttribute.PropertyName; mappedName = propertyAttribute.PropertyName;
#if !PocketPC && !NET20 #if !NET20
else if (dataMemberAttribute != null && dataMemberAttribute.Name != null) else if (dataMemberAttribute != null && dataMemberAttribute.Name != null)
mappedName = dataMemberAttribute.Name; mappedName = dataMemberAttribute.Name;
#endif #endif
@@ -980,7 +980,7 @@ namespace Newtonsoft.Json.Serialization
property.DefaultValueHandling = propertyAttribute._defaultValueHandling; property.DefaultValueHandling = propertyAttribute._defaultValueHandling;
hasMemberAttribute = true; hasMemberAttribute = true;
} }
#if !PocketPC && !NET20 #if !NET20
else if (dataMemberAttribute != null) else if (dataMemberAttribute != null)
{ {
property._required = (dataMemberAttribute.IsRequired) ? Required.AllowNull : Required.Default; property._required = (dataMemberAttribute.IsRequired) ? Required.AllowNull : Required.Default;
@@ -1045,7 +1045,7 @@ namespace Newtonsoft.Json.Serialization
if (memberSerialization == MemberSerialization.Fields) if (memberSerialization == MemberSerialization.Fields)
allowNonPublicAccess = true; allowNonPublicAccess = true;
#if !PocketPC && !NET20 #if !NET20
if (dataMemberAttribute != null) if (dataMemberAttribute != null)
{ {
allowNonPublicAccess = true; allowNonPublicAccess = true;
@@ -89,7 +89,6 @@ namespace Newtonsoft.Json.Serialization
// checked for after passed in converters and attribute specified converters // checked for after passed in converters and attribute specified converters
internal JsonConverter InternalConverter { get; set; } internal JsonConverter InternalConverter { get; set; }
#if !PocketPC
/// <summary> /// <summary>
/// Gets or sets the method called immediately after deserialization of the object. /// Gets or sets the method called immediately after deserialization of the object.
/// </summary> /// </summary>
@@ -113,7 +112,6 @@ namespace Newtonsoft.Json.Serialization
/// </summary> /// </summary>
/// <value>The method called before serialization of the object.</value> /// <value>The method called before serialization of the object.</value>
public MethodInfo OnSerializing { get; set; } public MethodInfo OnSerializing { get; set; }
#endif
/// <summary> /// <summary>
/// Gets or sets the default creator method used to create the object. /// Gets or sets the default creator method used to create the object.
@@ -135,34 +133,26 @@ namespace Newtonsoft.Json.Serialization
internal void InvokeOnSerializing(object o, StreamingContext context) internal void InvokeOnSerializing(object o, StreamingContext context)
{ {
#if !PocketPC
if (OnSerializing != null) if (OnSerializing != null)
OnSerializing.Invoke(o, new object[] {context}); OnSerializing.Invoke(o, new object[] {context});
#endif
} }
internal void InvokeOnSerialized(object o, StreamingContext context) internal void InvokeOnSerialized(object o, StreamingContext context)
{ {
#if !PocketPC
if (OnSerialized != null) if (OnSerialized != null)
OnSerialized.Invoke(o, new object[] {context}); OnSerialized.Invoke(o, new object[] {context});
#endif
} }
internal void InvokeOnDeserializing(object o, StreamingContext context) internal void InvokeOnDeserializing(object o, StreamingContext context)
{ {
#if !PocketPC
if (OnDeserializing != null) if (OnDeserializing != null)
OnDeserializing.Invoke(o, new object[] {context}); OnDeserializing.Invoke(o, new object[] {context});
#endif
} }
internal void InvokeOnDeserialized(object o, StreamingContext context) internal void InvokeOnDeserialized(object o, StreamingContext context)
{ {
#if !PocketPC
if (OnDeserialized != null) if (OnDeserialized != null)
OnDeserialized.Invoke(o, new object[] {context}); OnDeserialized.Invoke(o, new object[] {context});
#endif
} }
internal void InvokeOnError(object o, StreamingContext context, ErrorContext errorContext) internal void InvokeOnError(object o, StreamingContext context, ErrorContext errorContext)
@@ -561,10 +561,9 @@ To fix this error either change the JSON to a {1} or change the deserialized typ
if (id != null && isTemporaryListReference) if (id != null && isTemporaryListReference)
throw JsonSerializationException.Create(reader, "Cannot preserve reference to array or readonly list: {0}.".FormatWith(CultureInfo.InvariantCulture, contract.UnderlyingType)); throw JsonSerializationException.Create(reader, "Cannot preserve reference to array or readonly list: {0}.".FormatWith(CultureInfo.InvariantCulture, contract.UnderlyingType));
#if !PocketPC
if (contract.OnSerializing != null && isTemporaryListReference) if (contract.OnSerializing != null && isTemporaryListReference)
throw JsonSerializationException.Create(reader, "Cannot call OnSerializing on an array or readonly list: {0}.".FormatWith(CultureInfo.InvariantCulture, contract.UnderlyingType)); throw JsonSerializationException.Create(reader, "Cannot call OnSerializing on an array or readonly list: {0}.".FormatWith(CultureInfo.InvariantCulture, contract.UnderlyingType));
#endif
if (contract.OnError != null && isTemporaryListReference) if (contract.OnError != null && isTemporaryListReference)
throw JsonSerializationException.Create(reader, "Cannot call OnError on an array or readonly list: {0}.".FormatWith(CultureInfo.InvariantCulture, contract.UnderlyingType)); throw JsonSerializationException.Create(reader, "Cannot call OnError on an array or readonly list: {0}.".FormatWith(CultureInfo.InvariantCulture, contract.UnderlyingType));
@@ -292,7 +292,7 @@ namespace Newtonsoft.Json.Serialization
internal static bool TryConvertToString(object value, Type type, out string s) internal static bool TryConvertToString(object value, Type type, out string s)
{ {
#if !(PocketPC || NETFX_CORE || PORTABLE) #if !(NETFX_CORE || PORTABLE)
TypeConverter converter = ConvertUtils.GetConverter(type); TypeConverter converter = ConvertUtils.GetConverter(type);
// use the objectType's TypeConverter if it has one and can convert to a string // use the objectType's TypeConverter if it has one and can convert to a string
@@ -315,7 +315,7 @@ namespace Newtonsoft.Json.Serialization
} }
#endif #endif
#if SILVERLIGHT || PocketPC || NETFX_CORE #if SILVERLIGHT || NETFX_CORE
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();
@@ -44,7 +44,7 @@ using System.Runtime.Serialization;
namespace Newtonsoft.Json.Serialization namespace Newtonsoft.Json.Serialization
{ {
#if !SILVERLIGHT && !PocketPC && !NET20 && !NETFX_CORE #if !SILVERLIGHT && !NET20 && !NETFX_CORE
internal interface IMetadataTypeAttribute internal interface IMetadataTypeAttribute
{ {
Type MetadataClassType { get; } Type MetadataClassType { get; }
@@ -115,7 +115,7 @@ namespace Newtonsoft.Json.Serialization
} }
#endif #endif
#if !PocketPC && !NET20 #if !NET20
public static DataContractAttribute GetDataContractAttribute(Type type) public static DataContractAttribute GetDataContractAttribute(Type type)
{ {
// DataContractAttribute does not have inheritance // DataContractAttribute does not have inheritance
@@ -171,7 +171,7 @@ namespace Newtonsoft.Json.Serialization
if (objectAttribute != null) if (objectAttribute != null)
return objectAttribute.MemberSerialization; return objectAttribute.MemberSerialization;
#if !PocketPC && !NET20 #if !NET20
DataContractAttribute dataContractAttribute = GetDataContractAttribute(objectType); DataContractAttribute dataContractAttribute = GetDataContractAttribute(objectType);
if (dataContractAttribute != null) if (dataContractAttribute != null)
return MemberSerialization.OptIn; return MemberSerialization.OptIn;
@@ -225,7 +225,6 @@ namespace Newtonsoft.Json.Serialization
} }
#if !(NETFX_CORE || PORTABLE) #if !(NETFX_CORE || PORTABLE)
#if !PocketPC
public static TypeConverter GetTypeConverter(Type type) public static TypeConverter GetTypeConverter(Type type)
{ {
#if !SILVERLIGHT #if !SILVERLIGHT
@@ -237,7 +236,6 @@ namespace Newtonsoft.Json.Serialization
return (TypeConverter)ReflectionUtils.CreateInstance(converterType); return (TypeConverter)ReflectionUtils.CreateInstance(converterType);
return null; return null;
#endif
#endif #endif
} }
#endif #endif
@@ -23,7 +23,7 @@
// OTHER DEALINGS IN THE SOFTWARE. // OTHER DEALINGS IN THE SOFTWARE.
#endregion #endregion
#if !SILVERLIGHT && !PocketPC && !NET20 && !NETFX_CORE #if !SILVERLIGHT && !NET20 && !NETFX_CORE
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@@ -329,7 +329,7 @@ namespace Newtonsoft.Json.Utilities
if (targetType.IsInterface() || targetType.IsGenericTypeDefinition() || targetType.IsAbstract()) if (targetType.IsInterface() || targetType.IsGenericTypeDefinition() || targetType.IsAbstract())
throw new ArgumentException("Target type {0} is not a value type or a non-abstract class.".FormatWith(CultureInfo.InvariantCulture, targetType), "targetType"); throw new ArgumentException("Target type {0} is not a value type or a non-abstract class.".FormatWith(CultureInfo.InvariantCulture, targetType), "targetType");
#if !PocketPC && !NET20 #if !NET20
if (initialValue is DateTime && targetType == typeof(DateTimeOffset)) if (initialValue is DateTime && targetType == typeof(DateTimeOffset))
return new DateTimeOffset((DateTime)initialValue); return new DateTimeOffset((DateTime)initialValue);
#endif #endif
@@ -809,39 +809,7 @@ namespace Newtonsoft.Json.Utilities
{ {
ValidationUtils.ArgumentNotNull(type, "type"); ValidationUtils.ArgumentNotNull(type, "type");
#if !PocketPC
return Activator.CreateInstance(type, args); return Activator.CreateInstance(type, args);
#else
// CF doesn't have a Activator.CreateInstance overload that takes args
// lame
if (type.IsValueType && CollectionUtils.IsNullOrEmpty<object>(args))
return Activator.CreateInstance(type);
ConstructorInfo[] constructors = type.GetConstructors();
ConstructorInfo match = constructors.Where(c =>
{
ParameterInfo[] parameters = c.GetParameters();
if (parameters.Length != args.Length)
return false;
for (int i = 0; i < parameters.Length; i++)
{
ParameterInfo parameter = parameters[i];
object value = args[i];
if (!IsCompatibleValue(value, parameter.ParameterType))
return false;
}
return true;
}).FirstOrDefault();
if (match == null)
throw new Exception("Could not create '{0}' with given parameters.".FormatWith(CultureInfo.InvariantCulture, type));
return match.Invoke(args);
#endif
} }
public static void SplitFullyQualifiedTypeName(string fullyQualifiedTypeName, out string typeName, out string assemblyName) public static void SplitFullyQualifiedTypeName(string fullyQualifiedTypeName, out string typeName, out string assemblyName)