-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);
}
#if !PocketPC && !NET20
#if !NET20
[Test]
public void WriteValues()
{
@@ -25,7 +25,7 @@
using System;
using System.Collections.Generic;
#if !SILVERLIGHT && !PocketPC && !NET20 && !NETFX_CORE
#if !SILVERLIGHT && !NET20 && !NETFX_CORE
using System.Data.Linq;
#endif
#if !(SILVERLIGHT || NETFX_CORE)
@@ -27,7 +27,7 @@
using System;
using System.Collections.Generic;
#if !SILVERLIGHT && !PocketPC && !NET20 && !NETFX_CORE
#if !SILVERLIGHT && !NET20 && !NETFX_CORE
using System.Data.Linq;
#endif
#if !SILVERLIGHT && !NETFX_CORE
@@ -149,7 +149,7 @@ namespace Newtonsoft.Json.Tests.Converters
}
#endif
#if !PocketPC && !NET20
#if !NET20
[Test]
public void SerializeDateTimeOffset()
{
@@ -53,7 +53,7 @@ namespace Newtonsoft.Json.Tests.Converters
Assert.AreEqual("new Date(976918263055)", result);
}
#if !PocketPC && !NET20
#if !NET20
[Test]
public void SerializeDateTimeOffset()
{
@@ -25,7 +25,7 @@
using System;
using System.Collections.Generic;
#if !SILVERLIGHT && !PocketPC && !NET20 && !NETFX_CORE
#if !SILVERLIGHT && !NET20 && !NETFX_CORE
using System.Data.Linq;
#endif
#if !SILVERLIGHT && !NETFX_CORE
+2 -2
View File
@@ -231,7 +231,7 @@ now brown cow?", '"', true);
value = new DateTime(JsonConvert.InitialJavaScriptDateTicks, DateTimeKind.Utc);
Assert.AreEqual(@"""\/Date(0)\/""", JsonConvert.ToString((DateTime)value, DateFormatHandling.MicrosoftDateFormat, DateTimeZoneHandling.RoundtripKind));
#if !PocketPC && !NET20
#if !NET20
value = new DateTimeOffset(JsonConvert.InitialJavaScriptDateTicks, TimeSpan.Zero);
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");
Assert.AreEqual(1, i);
#if !PocketPC && !NET20
#if !NET20
DateTimeOffset d = JsonConvert.DeserializeObject<DateTimeOffset>(@"""\/Date(-59011455539000+0000)\/""");
Assert.AreEqual(new DateTimeOffset(new DateTime(100, 1, 1, 1, 1, 1, DateTimeKind.Utc)), d);
#endif
@@ -133,7 +133,7 @@ namespace Newtonsoft.Json.Tests
jsonWriter.WriteValue((decimal?)1.1m);
jsonWriter.WriteValue((DateTime?)null);
jsonWriter.WriteValue((DateTime?)new DateTime(JsonConvert.InitialJavaScriptDateTicks, DateTimeKind.Utc));
#if !PocketPC && !NET20
#if !NET20
jsonWriter.WriteValue((DateTimeOffset?)null);
jsonWriter.WriteValue((DateTimeOffset?)new DateTimeOffset(JsonConvert.InitialJavaScriptDateTicks, TimeSpan.Zero));
#endif
@@ -143,7 +143,7 @@ namespace Newtonsoft.Json.Tests
string json = sw.ToString();
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""]";
#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""]";
@@ -38,7 +38,7 @@ using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAtt
using Newtonsoft.Json.Linq;
using System.IO;
using System.Collections;
#if !PocketPC && !SILVERLIGHT && !NETFX_CORE
#if !SILVERLIGHT && !NETFX_CORE
using System.Web.UI;
#endif
#if NET20
@@ -44,7 +44,7 @@ namespace Newtonsoft.Json.Tests.Linq
[TestFixture]
public class JTokenReaderTest : TestFixtureBase
{
#if !PocketPC && !NET20
#if !NET20
[Test]
public void YahooFinance()
{
@@ -233,7 +233,7 @@ namespace Newtonsoft.Json.Tests.Linq
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)));
#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, 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));
@@ -446,7 +446,7 @@ namespace Newtonsoft.Json.Tests.Linq
public void ImplicitCastingTo()
{
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((DateTimeOffset?)null), (JValue)(DateTimeOffset?)null));
#endif
@@ -565,7 +565,7 @@ keyword such as type of business.""
});
}
#if !PocketPC && !NET20
#if !NET20
[Test]
public void ToStringJsonConverter()
{
@@ -23,7 +23,7 @@
// OTHER DEALINGS IN THE SOFTWARE.
#endregion
#if !(SILVERLIGHT || PocketPC || NET20 || NET35 || NETFX_CORE || PORTABLE)
#if !(SILVERLIGHT || NET20 || NET35 || NETFX_CORE || PORTABLE)
using System;
using System.Collections.Generic;
using System.Globalization;
@@ -35,8 +35,6 @@ using System.Security;
[assembly: AssemblyTitle("Json.NET Tests Windows Phone")]
#elif SILVERLIGHT
[assembly: AssemblyTitle("Json.NET Tests Silverlight")]
#elif PocketPC
[assembly: AssemblyTitle("Json.NET Tests Compact")]
#elif PORTABLE
[assembly: AssemblyTitle("Json.NET Tests Portable")]
#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
// by using the '*' as shown below:
[assembly: AssemblyVersion("4.5.0.0")]
#if !PocketPC
[assembly: AssemblyFileVersion("4.5.11.15810")]
#endif
@@ -199,7 +199,7 @@ namespace Newtonsoft.Json.Tests.Schema
GenerateSchemaAndSerializeFromType(new CircularReferenceWithIdClass());
GenerateSchemaAndSerializeFromType(new ClassWithArray());
GenerateSchemaAndSerializeFromType(new ClassWithGuid());
#if !NET20 && !PocketPC
#if !NET20
GenerateSchemaAndSerializeFromType(new NullableDateTimeTestClass());
#endif
#if !(SILVERLIGHT || NETFX_CORE || PORTABLE)
@@ -27,7 +27,7 @@ using System;
using System.ComponentModel;
using System.IO;
using System.Runtime.Serialization;
#if !(SILVERLIGHT || PocketPC || NET20 || NET35 || NETFX_CORE || PORTABLE)
#if !(SILVERLIGHT || NET20 || NET35 || NETFX_CORE || PORTABLE)
using System.Runtime.Serialization.Json;
#endif
using System.Text;
@@ -209,7 +209,7 @@ namespace Newtonsoft.Json.Tests.Serialization
{
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));
MemoryStream ms = new MemoryStream();
@@ -28,7 +28,7 @@ using System;
using System.Collections.Concurrent;
#endif
using System.Collections.Generic;
#if !SILVERLIGHT && !PocketPC && !NET20 && !NETFX_CORE
#if !SILVERLIGHT && !NET20 && !NETFX_CORE
using System.ComponentModel.DataAnnotations;
using System.Configuration;
using System.Runtime.CompilerServices;
@@ -53,7 +53,7 @@ using System.Collections.ObjectModel;
using Newtonsoft.Json.Bson;
using Newtonsoft.Json.Linq;
using Newtonsoft.Json.Converters;
#if !PocketPC && !NET20 && !WINDOWS_PHONE
#if !NET20 && !WINDOWS_PHONE
using System.Runtime.Serialization.Json;
#endif
using Newtonsoft.Json.Serialization;
@@ -173,7 +173,7 @@ namespace Newtonsoft.Json.Tests.Serialization
string jsonText = JsonConvert.SerializeObject(testDictionary);
#if !PocketPC && !NET20 && !WINDOWS_PHONE
#if !NET20 && !WINDOWS_PHONE
MemoryStream ms = new MemoryStream();
DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(Dictionary<string, object>));
serializer.WriteObject(ms, testDictionary);
@@ -432,7 +432,7 @@ keyword such as type of business.""
CollectionAssert.AreEqual(r1, r2);
}
#if !PocketPC && !NET20 && !WINDOWS_PHONE
#if !NET20 && !WINDOWS_PHONE
[Test]
public void Unicode()
{
@@ -1595,7 +1595,7 @@ keyword such as type of business.""
}
#endif
#if !PocketPC && !NET20
#if !NET20
[DataContract]
public class DataContractPrivateMembers
{
@@ -1982,7 +1982,7 @@ keyword such as type of business.""
Assert.AreEqual("Product 1", products[0].Name);
}
#if !PocketPC && !NET20
#if !NET20
[Test]
public void DeserializeEmptyStringToNullableDateTime()
{
@@ -2759,7 +2759,7 @@ Path '', line 1, position 2.",
public string Ethnicity { get; set; }
}
#if !NET20 && !PocketPC && !WINDOWS_PHONE
#if !NET20 && !WINDOWS_PHONE
public class DataContractJsonSerializerTestClass
{
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]);
}
#if !SILVERLIGHT && !NET20 && !PocketPC
#if !SILVERLIGHT && !NET20
[Test]
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);
}
#if !NET20 && !PocketPC && !SILVERLIGHT && !NETFX_CORE
#if !NET20 && !SILVERLIGHT && !NETFX_CORE
public class StringDictionaryTestClass
{
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");
}
#if !(SILVERLIGHT || PocketPC || NET20 || NETFX_CORE)
#if !(SILVERLIGHT || NET20 || NETFX_CORE)
[DataContract]
public struct StructISerializable : ISerializable
{
@@ -23,7 +23,6 @@
// OTHER DEALINGS IN THE SOFTWARE.
#endregion
#if !PocketPC
using System;
using System.Diagnostics;
using System.IO;
@@ -336,5 +335,4 @@ namespace Newtonsoft.Json.Tests.Serialization
}
}
}
}
#endif
}
@@ -26,7 +26,7 @@
using System;
using System.Runtime.Serialization;
#if !PocketPC && !NET20
#if !NET20
namespace Newtonsoft.Json.Tests.TestObjects
{
[DataContract]
@@ -23,7 +23,7 @@
// OTHER DEALINGS IN THE SOFTWARE.
#endregion
#if !PocketPC && !NET20
#if !NET20
using System;
using System.Collections.Generic;
using System.ComponentModel;
@@ -27,7 +27,7 @@ using System.ComponentModel;
namespace Newtonsoft.Json.Tests.TestObjects
{
#if !PocketPC && !NETFX_CORE
#if !NETFX_CORE
[Description("DefaultValueAttributeTestClass description!")]
#endif
public sealed class DefaultValueAttributeTestClass
@@ -23,7 +23,7 @@
// OTHER DEALINGS IN THE SOFTWARE.
#endregion
#if !PocketPC && !NET20
#if !NET20
using System;
using System.Collections.Generic;
using System.Linq;
@@ -29,7 +29,7 @@ using System.ComponentModel;
namespace Newtonsoft.Json.Tests.TestObjects
{
[JsonObject(Id = "Person", Title = "Title!", Description = "JsonObjectAttribute description!", MemberSerialization = MemberSerialization.OptIn)]
#if !PocketPC && !NETFX_CORE
#if !NETFX_CORE
[Description("DescriptionAttribute description!")]
#endif
public class Person
@@ -23,7 +23,6 @@
// OTHER DEALINGS IN THE SOFTWARE.
#endregion
#if !PocketPC
using System.Collections.Generic;
using System.Runtime.Serialization;
@@ -78,5 +77,4 @@ namespace Newtonsoft.Json.Tests.TestObjects
Member4 = "This value was set after deserialization.";
}
}
}
#endif
}
@@ -23,7 +23,6 @@
// OTHER DEALINGS IN THE SOFTWARE.
#endregion
#if !PocketPC
using System.Collections.ObjectModel;
using System.Runtime.Serialization;
@@ -78,5 +77,4 @@ namespace Newtonsoft.Json.Tests.TestObjects
Member4 = "This value was set after deserialization.";
}
}
}
#endif
}
@@ -23,7 +23,6 @@
// OTHER DEALINGS IN THE SOFTWARE.
#endregion
#if !PocketPC
using System;
using System.Runtime.Serialization;
using Newtonsoft.Json.Serialization;
@@ -97,5 +96,4 @@ namespace Newtonsoft.Json.Tests.TestObjects
errorContext.Handled = true;
}
}
}
#endif
}
@@ -23,7 +23,6 @@
// OTHER DEALINGS IN THE SOFTWARE.
#endregion
#if !PocketPC
using System;
using System.Runtime.Serialization;
using Newtonsoft.Json.Serialization;
@@ -81,5 +80,4 @@ namespace Newtonsoft.Json.Tests.TestObjects
Member4 = "This value was set after deserialization.";
}
}
}
#endif
}
+1 -1
View File
@@ -148,7 +148,7 @@ namespace Newtonsoft.Json.Bson
ticks = JsonConvert.ConvertDateTimeToJavaScriptTicks(dateTime, false);
}
#if !PocketPC && !NET20
#if !NET20
else
{
DateTimeOffset dateTimeOffset = (DateTimeOffset)value.Value;
+1 -1
View File
@@ -407,7 +407,7 @@ namespace Newtonsoft.Json.Bson
AddValue(value, BsonType.Date);
}
#if !PocketPC && !NET20
#if !NET20
/// <summary>
/// Writes a <see cref="DateTimeOffset"/> value.
/// </summary>
@@ -43,7 +43,7 @@ namespace Newtonsoft.Json.Converters
{
if (objectType == typeof(DateTime) || objectType == typeof(DateTime?))
return true;
#if !PocketPC && !NET20
#if !NET20
if (objectType == typeof(DateTimeOffset) || objectType == typeof(DateTimeOffset?))
return true;
#endif
@@ -90,7 +90,7 @@ namespace Newtonsoft.Json.Converters
text = dateTime.ToString(_dateTimeFormat ?? DefaultDateTimeFormat, Culture);
}
#if !PocketPC && !NET20
#if !NET20
else if (value is DateTimeOffset)
{
DateTimeOffset dateTimeOffset = (DateTimeOffset)value;
@@ -134,7 +134,7 @@ namespace Newtonsoft.Json.Converters
if (reader.TokenType == JsonToken.Date)
{
#if !PocketPC && !NET20
#if !NET20
if (t == typeof(DateTimeOffset))
return new DateTimeOffset((DateTime)reader.Value);
#endif
@@ -150,7 +150,7 @@ namespace Newtonsoft.Json.Converters
if (string.IsNullOrEmpty(dateText) && nullable)
return null;
#if !PocketPC && !NET20
#if !NET20
if (t == typeof(DateTimeOffset))
{
if (!string.IsNullOrEmpty(_dateTimeFormat))
@@ -50,7 +50,7 @@ namespace Newtonsoft.Json.Converters
DateTime utcDateTime = dateTime.ToUniversalTime();
ticks = JsonConvert.ConvertDateTimeToJavaScriptTicks(utcDateTime);
}
#if !PocketPC && !NET20
#if !NET20
else if (value is DateTimeOffset)
{
DateTimeOffset dateTimeOffset = (DateTimeOffset)value;
@@ -107,7 +107,7 @@ namespace Newtonsoft.Json.Converters
if (reader.TokenType != JsonToken.EndConstructor)
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))
return new DateTimeOffset(d);
#endif
+3 -3
View File
@@ -137,7 +137,7 @@ namespace Newtonsoft.Json
return value;
}
#if !PocketPC && !NET20
#if !NET20
/// <summary>
/// Converts the <see cref="DateTimeOffset"/> to its JSON string representation.
/// </summary>
@@ -656,7 +656,7 @@ namespace Newtonsoft.Json
#endif
}
}
#if !PocketPC && !NET20
#if !NET20
else if (value is DateTimeOffset)
{
return ToString((DateTimeOffset) value);
@@ -711,7 +711,7 @@ namespace Newtonsoft.Json
if (ReflectionUtils.IsNullableType(type))
type = Nullable.GetUnderlyingType(type);
#if !PocketPC && !NET20
#if !NET20
if (type == typeof (DateTimeOffset))
return true;
#endif
+1 -1
View File
@@ -507,7 +507,7 @@ namespace Newtonsoft.Json
}
}
#if !PocketPC && !NET20
#if !NET20
/// <summary>
/// Writes a <see cref="DateTimeOffset"/> value.
/// </summary>
+4 -4
View File
@@ -521,7 +521,7 @@ namespace Newtonsoft.Json
WriteEndConstructor();
break;
case JsonToken.Date:
#if !PocketPC && !NET20
#if !NET20
if (reader.Value is DateTimeOffset)
WriteValue((DateTimeOffset)reader.Value);
else
@@ -949,7 +949,7 @@ namespace Newtonsoft.Json
InternalWriteValue(JsonToken.Date);
}
#if !PocketPC && !NET20
#if !NET20
/// <summary>
/// Writes a <see cref="DateTimeOffset"/> value.
/// </summary>
@@ -1150,7 +1150,7 @@ namespace Newtonsoft.Json
WriteValue(value.Value);
}
#if !PocketPC && !NET20
#if !NET20
/// <summary>
/// Writes a <see cref="Nullable{DateTimeOffset}"/> value.
/// </summary>
@@ -1340,7 +1340,7 @@ namespace Newtonsoft.Json
#endif
}
}
#if !PocketPC && !NET20
#if !NET20
else if (value is DateTimeOffset)
{
if (nullable)
+5 -5
View File
@@ -454,7 +454,7 @@ namespace Newtonsoft.Json.Linq
return Convert.ToBoolean(v.Value, CultureInfo.InvariantCulture);
}
#if !PocketPC && !NET20
#if !NET20
/// <summary>
/// Performs an explicit conversion from <see cref="Newtonsoft.Json.Linq.JToken"/> to <see cref="System.DateTimeOffset"/>.
/// </summary>
@@ -522,7 +522,7 @@ namespace Newtonsoft.Json.Linq
return (v.Value != null) ? (DateTime?)Convert.ToDateTime(v.Value, CultureInfo.InvariantCulture) : null;
}
#if !PocketPC && !NET20
#if !NET20
/// <summary>
/// Performs an explicit conversion from <see cref="Newtonsoft.Json.Linq.JToken"/> to <see cref="Nullable{DateTimeOffset}"/>.
/// </summary>
@@ -1036,7 +1036,7 @@ namespace Newtonsoft.Json.Linq
return new JValue(value);
}
#if !PocketPC && !NET20
#if !NET20
/// <summary>
/// Performs an implicit conversion from <see cref="DateTimeOffset"/> to <see cref="JToken"/>.
/// </summary>
@@ -1078,7 +1078,7 @@ namespace Newtonsoft.Json.Linq
return new JValue(value);
}
#if !PocketPC && !NET20
#if !NET20
/// <summary>
/// Performs an implicit conversion from <see cref="Nullable{DateTimeOffset}"/> to <see cref="JToken"/>.
/// </summary>
@@ -1517,7 +1517,7 @@ namespace Newtonsoft.Json.Linq
return (string) this;
}
#if !PocketPC && !NET20
#if !NET20
if (objectType == typeof (DateTimeOffset))
{
if (isNullable)
+1 -1
View File
@@ -377,7 +377,7 @@ namespace Newtonsoft.Json.Linq
AddValue(value, JsonToken.Date);
}
#if !PocketPC && !NET20
#if !NET20
/// <summary>
/// Writes a <see cref="DateTimeOffset"/> value.
/// </summary>
+2 -2
View File
@@ -460,7 +460,7 @@ namespace Newtonsoft.Json.Linq
return JTokenType.Float;
else if (value is DateTime)
return JTokenType.Date;
#if !PocketPC && !NET20
#if !NET20
else if (value is DateTimeOffset)
return JTokenType.Date;
#endif
@@ -573,7 +573,7 @@ namespace Newtonsoft.Json.Linq
writer.WriteValue(Convert.ToBoolean(_value, CultureInfo.InvariantCulture));
return;
case JTokenType.Date:
#if !PocketPC && !NET20
#if !NET20
if (_value is DateTimeOffset)
writer.WriteValue((DateTimeOffset)_value);
else
@@ -36,8 +36,6 @@ using System.Security;
[assembly: AssemblyTitle("Json.NET Windows Phone")]
#elif SILVERLIGHT
[assembly: AssemblyTitle("Json.NET Silverlight")]
#elif PocketPC
[assembly: AssemblyTitle("Json.NET Compact")]
#elif PORTABLE
[assembly: AssemblyTitle("Json.NET Portable")]
#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
// by using the '*' as shown below:
[assembly: AssemblyVersion("4.5.0.0")]
#if !PocketPC
[assembly: AssemblyFileVersion("4.5.11.15810")]
#endif
[assembly: CLSCompliant(true)]
@@ -274,7 +274,7 @@ namespace Newtonsoft.Json.Serialization
if (memberSerialization != MemberSerialization.Fields)
{
#if !PocketPC && !NET20
#if !NET20
DataContractAttribute dataContractAttribute = JsonTypeReflector.GetDataContractAttribute(objectType);
#endif
@@ -297,7 +297,7 @@ namespace Newtonsoft.Json.Serialization
// or are a field if serializing just fields
if (JsonTypeReflector.GetAttribute<JsonPropertyAttribute>(member.GetCustomAttributeProvider()) != null)
serializableMembers.Add(member);
#if !PocketPC && !NET20
#if !NET20
else if (dataContractAttribute != null && JsonTypeReflector.GetAttribute<DataMemberAttribute>(member.GetCustomAttributeProvider()) != null)
serializableMembers.Add(member);
#endif
@@ -307,7 +307,7 @@ namespace Newtonsoft.Json.Serialization
}
}
#if !PocketPC && !SILVERLIGHT && !NET20
#if !SILVERLIGHT && !NET20
Type match;
// don't include EntityKey on entities objects... this is a bit hacky
if (objectType.AssignableToTypeName("System.Data.Objects.DataClasses.EntityObject", out match))
@@ -328,7 +328,7 @@ namespace Newtonsoft.Json.Serialization
return serializableMembers;
}
#if !PocketPC && !SILVERLIGHT && !NET20
#if !SILVERLIGHT && !NET20
private bool ShouldSerializeEntityMember(MemberInfo memberInfo)
{
PropertyInfo propertyInfo = memberInfo as PropertyInfo;
@@ -508,7 +508,7 @@ namespace Newtonsoft.Json.Serialization
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()")]
#endif
private void InitializeContract(JsonContract contract)
@@ -518,7 +518,7 @@ namespace Newtonsoft.Json.Serialization
{
contract.IsReference = containerAttribute._isReference;
}
#if !PocketPC && !NET20
#if !NET20
else
{
DataContractAttribute dataContractAttribute = JsonTypeReflector.GetDataContractAttribute(contract.NonNullableUnderlyingType);
@@ -805,7 +805,7 @@ namespace Newtonsoft.Json.Serialization
if (type == typeof(Type) || type.IsSubclassOf(typeof(Type)))
return true;
#if SILVERLIGHT || PocketPC
#if SILVERLIGHT
if (type == typeof(Guid) || type == typeof(Uri) || type == typeof(TimeSpan))
return true;
#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)
{
#if !PocketPC && !NET20
#if !NET20
DataContractAttribute dataContractAttribute = JsonTypeReflector.GetDataContractAttribute(declaringType);
MemberInfo memberInfo = null;
@@ -962,7 +962,7 @@ namespace Newtonsoft.Json.Serialization
string mappedName;
if (propertyAttribute != null && propertyAttribute.PropertyName != null)
mappedName = propertyAttribute.PropertyName;
#if !PocketPC && !NET20
#if !NET20
else if (dataMemberAttribute != null && dataMemberAttribute.Name != null)
mappedName = dataMemberAttribute.Name;
#endif
@@ -980,7 +980,7 @@ namespace Newtonsoft.Json.Serialization
property.DefaultValueHandling = propertyAttribute._defaultValueHandling;
hasMemberAttribute = true;
}
#if !PocketPC && !NET20
#if !NET20
else if (dataMemberAttribute != null)
{
property._required = (dataMemberAttribute.IsRequired) ? Required.AllowNull : Required.Default;
@@ -1045,7 +1045,7 @@ namespace Newtonsoft.Json.Serialization
if (memberSerialization == MemberSerialization.Fields)
allowNonPublicAccess = true;
#if !PocketPC && !NET20
#if !NET20
if (dataMemberAttribute != null)
{
allowNonPublicAccess = true;
@@ -89,7 +89,6 @@ namespace Newtonsoft.Json.Serialization
// checked for after passed in converters and attribute specified converters
internal JsonConverter InternalConverter { get; set; }
#if !PocketPC
/// <summary>
/// Gets or sets the method called immediately after deserialization of the object.
/// </summary>
@@ -113,7 +112,6 @@ namespace Newtonsoft.Json.Serialization
/// </summary>
/// <value>The method called before serialization of the object.</value>
public MethodInfo OnSerializing { get; set; }
#endif
/// <summary>
/// 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)
{
#if !PocketPC
if (OnSerializing != null)
OnSerializing.Invoke(o, new object[] {context});
#endif
}
internal void InvokeOnSerialized(object o, StreamingContext context)
{
#if !PocketPC
if (OnSerialized != null)
OnSerialized.Invoke(o, new object[] {context});
#endif
}
internal void InvokeOnDeserializing(object o, StreamingContext context)
{
#if !PocketPC
if (OnDeserializing != null)
OnDeserializing.Invoke(o, new object[] {context});
#endif
}
internal void InvokeOnDeserialized(object o, StreamingContext context)
{
#if !PocketPC
if (OnDeserialized != null)
OnDeserialized.Invoke(o, new object[] {context});
#endif
}
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)
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)
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)
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)
{
#if !(PocketPC || NETFX_CORE || PORTABLE)
#if !(NETFX_CORE || PORTABLE)
TypeConverter converter = ConvertUtils.GetConverter(type);
// use the objectType's TypeConverter if it has one and can convert to a string
@@ -315,7 +315,7 @@ namespace Newtonsoft.Json.Serialization
}
#endif
#if SILVERLIGHT || PocketPC || NETFX_CORE
#if SILVERLIGHT || NETFX_CORE
if (value is Guid || value is Uri || value is TimeSpan)
{
s = value.ToString();
@@ -44,7 +44,7 @@ using System.Runtime.Serialization;
namespace Newtonsoft.Json.Serialization
{
#if !SILVERLIGHT && !PocketPC && !NET20 && !NETFX_CORE
#if !SILVERLIGHT && !NET20 && !NETFX_CORE
internal interface IMetadataTypeAttribute
{
Type MetadataClassType { get; }
@@ -115,7 +115,7 @@ namespace Newtonsoft.Json.Serialization
}
#endif
#if !PocketPC && !NET20
#if !NET20
public static DataContractAttribute GetDataContractAttribute(Type type)
{
// DataContractAttribute does not have inheritance
@@ -171,7 +171,7 @@ namespace Newtonsoft.Json.Serialization
if (objectAttribute != null)
return objectAttribute.MemberSerialization;
#if !PocketPC && !NET20
#if !NET20
DataContractAttribute dataContractAttribute = GetDataContractAttribute(objectType);
if (dataContractAttribute != null)
return MemberSerialization.OptIn;
@@ -225,7 +225,6 @@ namespace Newtonsoft.Json.Serialization
}
#if !(NETFX_CORE || PORTABLE)
#if !PocketPC
public static TypeConverter GetTypeConverter(Type type)
{
#if !SILVERLIGHT
@@ -237,7 +236,6 @@ namespace Newtonsoft.Json.Serialization
return (TypeConverter)ReflectionUtils.CreateInstance(converterType);
return null;
#endif
#endif
}
#endif
@@ -23,7 +23,7 @@
// OTHER DEALINGS IN THE SOFTWARE.
#endregion
#if !SILVERLIGHT && !PocketPC && !NET20 && !NETFX_CORE
#if !SILVERLIGHT && !NET20 && !NETFX_CORE
using System;
using System.Collections.Generic;
using System.Linq;
@@ -329,7 +329,7 @@ namespace Newtonsoft.Json.Utilities
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");
#if !PocketPC && !NET20
#if !NET20
if (initialValue is DateTime && targetType == typeof(DateTimeOffset))
return new DateTimeOffset((DateTime)initialValue);
#endif
@@ -809,39 +809,7 @@ namespace Newtonsoft.Json.Utilities
{
ValidationUtils.ArgumentNotNull(type, "type");
#if !PocketPC
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)