-Added Portable Class Library build

This commit is contained in:
James Newton-King
2012-04-18 21:02:34 +12:00
parent 6725edb75c
commit 10256fcf68
85 changed files with 1005 additions and 344 deletions
+1
View File
@@ -17,6 +17,7 @@
$workingDir = "$baseDir\Working"
$builds = @(
@{Name = "Newtonsoft.Json"; TestsName = "Newtonsoft.Json.Tests"; Constants=""; FinalDir="Net40"; NuGetDir = "net40"; Framework="net-4.0"; Sign=$true},
@{Name = "Newtonsoft.Json.Portable"; TestsName = "Newtonsoft.Json.Tests.Portable"; Constants="PORTABLE"; FinalDir="Portable"; NuGetDir = $null; Framework="net-4.0"; Sign=$true},
@{Name = "Newtonsoft.Json.Metro"; TestsName = $null; Constants="NETFX_CORE"; FinalDir="Metro"; NuGetDir = "winrt45"; Framework="net-4.5"; Sign=$true},
# unsigned SL/WP
+32
View File
@@ -0,0 +1,32 @@
Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Lib", "Lib", "{620042D9-2753-48F5-BEDE-3905248781D2}"
ProjectSection(SolutionItems) = preProject
Lib\NUnit\DotNet\nunit.framework.dll = Lib\NUnit\DotNet\nunit.framework.dll
Lib\NUnit\DotNet\nunit.framework.xml = Lib\NUnit\DotNet\nunit.framework.xml
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Newtonsoft.Json.Portable", "Newtonsoft.Json\Newtonsoft.Json.Portable.csproj", "{959F7F85-C98B-4876-971A-9036224578E4}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Newtonsoft.Json.Tests.Portable", "Newtonsoft.Json.Tests\Newtonsoft.Json.Tests.Portable.csproj", "{3E6E2335-B079-4B5B-A65A-9D586914BCBB}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{959F7F85-C98B-4876-971A-9036224578E4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{959F7F85-C98B-4876-971A-9036224578E4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{959F7F85-C98B-4876-971A-9036224578E4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{959F7F85-C98B-4876-971A-9036224578E4}.Release|Any CPU.Build.0 = Release|Any CPU
{3E6E2335-B079-4B5B-A65A-9D586914BCBB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3E6E2335-B079-4B5B-A65A-9D586914BCBB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3E6E2335-B079-4B5B-A65A-9D586914BCBB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3E6E2335-B079-4B5B-A65A-9D586914BCBB}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
@@ -29,7 +29,7 @@ namespace Newtonsoft.Json.Tests.Converters
public byte[] NullByteArray { get; set; }
}
#if !SILVERLIGHT && !PocketPC && !NET20 && !NETFX_CORE
#if !(SILVERLIGHT || NET20 || NETFX_CORE || PORTABLE)
[Test]
public void DeserializeBinaryClass()
{
@@ -87,7 +87,7 @@ namespace Newtonsoft.Json.Tests.Converters
byteArrayClass.ByteArray = TestData;
byteArrayClass.NullByteArray = null;
string json = JsonConvert.SerializeObject(byteArrayClass, Formatting.Indented, new BinaryConverter());
string json = JsonConvert.SerializeObject(byteArrayClass, Formatting.Indented);
Assert.AreEqual(@"{
""ByteArray"": ""VGhpcyBpcyBzb21lIHRlc3QgZGF0YSEhIQ=="",
@@ -95,7 +95,7 @@ namespace Newtonsoft.Json.Tests.Converters
}", json);
}
#if !(SILVERLIGHT || NETFX_CORE)
#if !(SILVERLIGHT || NETFX_CORE || PORTABLE)
public class SqlBinaryClass
{
public SqlBinary SqlBinary { get; set; }
@@ -145,7 +145,7 @@ namespace Newtonsoft.Json.Tests.Converters
""NullByteArray"": null
}";
ByteArrayClass byteArrayClass = JsonConvert.DeserializeObject<ByteArrayClass>(json, new BinaryConverter());
ByteArrayClass byteArrayClass = JsonConvert.DeserializeObject<ByteArrayClass>(json);
CollectionAssert.AreEquivalent(TestData, byteArrayClass.ByteArray);
Assert.AreEqual(null, byteArrayClass.NullByteArray);
@@ -1,4 +1,4 @@
#if !(SILVERLIGHT || NETFX_CORE)
#if !(SILVERLIGHT || NETFX_CORE || PORTABLE)
using System;
using Newtonsoft.Json.Converters;
#if !NETFX_CORE
@@ -1,4 +1,4 @@
#if !(SILVERLIGHT || NETFX_CORE)
#if !(SILVERLIGHT || NETFX_CORE || PORTABLE)
using System;
#if !NETFX_CORE
using NUnit.Framework;
@@ -1,4 +1,4 @@
#if !(NET35 || NET20 || WINDOWS_PHONE)
#if !(NET35 || NET20 || WINDOWS_PHONE || PORTABLE)
using System;
using System.Collections.Generic;
@@ -23,7 +23,7 @@
// OTHER DEALINGS IN THE SOFTWARE.
#endregion
#if !SILVERLIGHT && !NETFX_CORE
#if !(SILVERLIGHT || NETFX_CORE || PORTABLE)
using System;
using System.Collections.Generic;
using Newtonsoft.Json.Tests.Serialization;
+2 -2
View File
@@ -285,7 +285,7 @@ now brown cow?", '"', true);
value = null;
Assert.AreEqual("null", JsonConvert.ToString(value));
#if !NETFX_CORE
#if !(NETFX_CORE || PORTABLE)
value = DBNull.Value;
Assert.AreEqual("null", JsonConvert.ToString(value));
#endif
@@ -679,7 +679,7 @@ now brown cow?", '"', true);
return (T)converter.ReadJson(reader, typeof(T), null, null);
}
#if !(NET20 || NET35 || SILVERLIGHT)
#if !(NET20 || NET35 || SILVERLIGHT || PORTABLE)
[Test]
public void Async()
{
@@ -23,7 +23,7 @@
// OTHER DEALINGS IN THE SOFTWARE.
#endregion
#if !PocketPC && !SILVERLIGHT && !NETFX_CORE
#if !(SILVERLIGHT || NETFX_CORE || PORTABLE)
using NUnit.Framework;
using System.Web.UI;
using Newtonsoft.Json.Linq;
@@ -23,7 +23,7 @@
// OTHER DEALINGS IN THE SOFTWARE.
#endregion
#if !SILVERLIGHT && !NETFX_CORE
#if !(SILVERLIGHT || NETFX_CORE || PORTABLE)
using NUnit.Framework;
using Newtonsoft.Json.Linq;
@@ -1,4 +1,4 @@
#if !(NET35 || NET20)
#if !(NET35 || NET20 || PORTABLE)
using System;
using System.Collections.Generic;
using System.Dynamic;
@@ -424,7 +424,7 @@ Parameter name: index"
}
#if !SILVERLIGHT && !NETFX_CORE
#if !(SILVERLIGHT || NETFX_CORE || PORTABLE)
[Test]
public void ITypedListGetItemProperties()
{
@@ -648,7 +648,7 @@ Parameter name: arrayIndex"
Assert.AreEqual(p4, l[1]);
}
#if !PocketPC && !SILVERLIGHT && !NET20 && !NETFX_CORE
#if !(SILVERLIGHT || NET20 || NETFX_CORE || PORTABLE)
[Test]
public void PropertyChanging()
{
@@ -1205,7 +1205,7 @@ Parameter name: arrayIndex"
});
}
#if !SILVERLIGHT && !NETFX_CORE
#if !(SILVERLIGHT || NETFX_CORE || PORTABLE)
[Test]
public void IBindingListSortDirection()
{
@@ -1391,7 +1391,7 @@ Parameter name: arrayIndex"
Assert.AreEqual(2, (int)o["Test1"]);
}
#endif
#if SILVERLIGHT || !(NET20 || NET35)
#if SILVERLIGHT || !(NET20 || NET35 || PORTABLE)
[Test]
public void CollectionChanged()
{
@@ -1521,7 +1521,7 @@ Parameter name: arrayIndex"
Assert.AreEqual("Name2", value);
}
#if !NETFX_CORE
#if !(NETFX_CORE || PORTABLE)
[Test]
public void WriteObjectNullDBNullValue()
{
@@ -1652,7 +1652,7 @@ Parameter name: arrayIndex"
});
}
#if !SILVERLIGHT && !NETFX_CORE
#if !(SILVERLIGHT || NETFX_CORE || PORTABLE)
[Test]
public void GetProperties()
{
@@ -31,7 +31,7 @@ namespace Newtonsoft.Json.Tests.Linq
Assert.AreEqual(p, p.Value.Parent);
}
#if !SILVERLIGHT && !NETFX_CORE
#if !(SILVERLIGHT || NETFX_CORE || PORTABLE)
[Test]
public void ListChanged()
{
@@ -708,7 +708,7 @@ namespace Newtonsoft.Json.Tests.Linq
Assert.IsTrue(a.DeepEquals(a2));
}
#if !SILVERLIGHT && !NETFX_CORE
#if !(SILVERLIGHT || NETFX_CORE || PORTABLE)
[Test]
public void Clone()
{
@@ -69,7 +69,7 @@ namespace Newtonsoft.Json.Tests.Linq
Assert.AreEqual("Pie", v.Value);
Assert.AreEqual(JTokenType.String, v.Type);
#if !NETFX_CORE
#if !(NETFX_CORE || PORTABLE)
v.Value = DBNull.Value;
Assert.AreEqual(DBNull.Value, v.Value);
Assert.AreEqual(JTokenType.Null, v.Type);
@@ -719,7 +719,7 @@ keyword such as type of business.""
Assert.AreEqual(new DateTime(2000, 10, 15, 5, 5, 5, DateTimeKind.Utc), d);
}
#if !(NET20 || NET35 || SILVERLIGHT)
#if !(NET20 || NET35 || SILVERLIGHT || PORTABLE)
[Test]
public void CovariantIJEnumerable()
{
@@ -0,0 +1,326 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>9.0.30729</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{3E6E2335-B079-4B5B-A65A-9D586914BCBB}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Newtonsoft.Json.Tests</RootNamespace>
<AssemblyName>Newtonsoft.Json.Tests</AssemblyName>
<SccProjectName>
</SccProjectName>
<SccLocalPath>
</SccLocalPath>
<SccAuxPath>
</SccAuxPath>
<SccProvider>
</SccProvider>
<FileUpgradeFlags>
</FileUpgradeFlags>
<OldToolsVersion>3.5</OldToolsVersion>
<UpgradeBackupLocation>
</UpgradeBackupLocation>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<SignAssembly>false</SignAssembly>
<AssemblyOriginatorKeyFile>
</AssemblyOriginatorKeyFile>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
<TargetFrameworkProfile>
</TargetFrameworkProfile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\Portable\</OutputPath>
<DefineConstants>TRACE;DEBUG;PORTABLE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\Portable\</OutputPath>
<DefineConstants>TRACE;PORTABLE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.CSharp" />
<Reference Include="nunit.framework, Version=2.4.3.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\Lib\NUnit\DotNet\nunit.framework.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.ComponentModel.DataAnnotations">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data" />
<Reference Include="System.Data.Entity">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data.Linq">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Drawing" />
<Reference Include="System.Runtime.Serialization">
<RequiredTargetFramework>3.0</RequiredTargetFramework>
</Reference>
<Reference Include="System.Security" />
<Reference Include="System.ServiceModel">
<RequiredTargetFramework>3.0</RequiredTargetFramework>
</Reference>
<Reference Include="System.ServiceModel.Web">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Web" />
<Reference Include="System.Web.Extensions">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Xml" />
<Reference Include="System.Xml.Linq">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Bson\BsonWriterTests.cs" />
<Compile Include="Bson\BsonReaderTests.cs" />
<Compile Include="Converters\BinaryConverterTests.cs" />
<Compile Include="Converters\ExpandoObjectConverterTests.cs" />
<Compile Include="Converters\RegexConverterTests.cs" />
<Compile Include="Converters\DataTableConverterTests.cs" />
<Compile Include="Converters\DataSetConverterTests.cs" />
<Compile Include="Converters\CustomCreationConverterTests.cs" />
<Compile Include="Converters\ObjectIdConverterTests.cs" />
<Compile Include="Converters\StringEnumConverterTests.cs" />
<Compile Include="Converters\VersionConverterTests.cs" />
<Compile Include="FileSystemEntityModel.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>FileSystemEntityModel.edmx</DependentUpon>
</Compile>
<Compile Include="JsonArrayAttributeTests.cs" />
<Compile Include="ExceptionTests.cs" />
<Compile Include="JsonValidatingReaderTests.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="Serialization\ConstructorHandlingTests.cs" />
<Compile Include="Serialization\ContractResolverTests.cs" />
<Compile Include="Serialization\DefaultValueHandlingTests.cs" />
<Compile Include="Serialization\DynamicTests.cs" />
<Compile Include="Serialization\WebApiIntegrationTests.cs" />
<Compile Include="Serialization\JsonPropertyCollectionTests.cs" />
<Compile Include="Serialization\NullValueHandlingTests.cs" />
<Compile Include="TestObjects\Bar.cs" />
<Compile Include="TestObjects\Car.cs" />
<Compile Include="TestObjects\Computer.cs" />
<Compile Include="TestObjects\ConstructorReadonlyFields.cs" />
<Compile Include="TestObjects\Container.cs" />
<Compile Include="TestObjects\ContentBaseClass.cs" />
<Compile Include="TestObjects\ContentSubClass.cs" />
<Compile Include="TestObjects\Foo.cs" />
<Compile Include="TestObjects\HolderClass.cs" />
<Compile Include="TestObjects\IPrivateImplementationA.cs" />
<Compile Include="TestObjects\IPrivateImplementationB.cs" />
<Compile Include="TestObjects\IPrivateOverriddenImplementation.cs" />
<Compile Include="TestObjects\ListOfIds.cs" />
<Compile Include="TestObjects\Movie.cs" />
<Compile Include="TestObjects\PersonError.cs" />
<Compile Include="TestObjects\PersonPropertyClass.cs" />
<Compile Include="TestObjects\PrivateConstructorTestClass.cs" />
<Compile Include="TestObjects\PrivateConstructorWithPublicParametizedConstructorTestClass.cs" />
<Compile Include="TestObjects\Content.cs" />
<Compile Include="TestObjects\DateTimeErrorObjectCollection.cs" />
<Compile Include="Serialization\EntitiesSerializationTests.cs" />
<Compile Include="TestObjects\DictionaryInterfaceClass.cs" />
<Compile Include="TestObjects\Event.cs" />
<Compile Include="TestObjects\GoogleMapGeocoderStructure.cs" />
<Compile Include="TestObjects\InterfacePropertyTestClass.cs" />
<Compile Include="TestObjects\JsonPropertyClass.cs" />
<Compile Include="TestObjects\ListErrorObject.cs" />
<Compile Include="TestObjects\ListErrorObjectCollection.cs" />
<Compile Include="Serialization\MissingMemberHandlingTests.cs" />
<Compile Include="Serialization\PopulateTests.cs" />
<Compile Include="Serialization\SerializationErrorHandlingTests.cs" />
<Compile Include="Serialization\SerializationEventAttributeTests.cs" />
<Compile Include="Schema\ExtensionsTests.cs" />
<Compile Include="Schema\JsonSchemaModelBuilderTests.cs" />
<Compile Include="Schema\JsonSchemaNodeTests.cs" />
<Compile Include="Serialization\CamelCasePropertyNamesContractResolverTests.cs" />
<Compile Include="Serialization\PreserveReferencesHandlingTests.cs" />
<Compile Include="Serialization\TypeNameHandlingTests.cs" />
<Compile Include="TestObjects\ListTestClass.cs" />
<Compile Include="TestObjects\LogEntry.cs" />
<Compile Include="TestObjects\NonRequest.cs" />
<Compile Include="TestObjects\ObjectArrayPropertyTest.cs" />
<Compile Include="TestObjects\PrivateImplementationAClass.cs" />
<Compile Include="TestObjects\PrivateImplementationBClass.cs" />
<Compile Include="TestObjects\PublicParametizedConstructorRequiringConverterTestClass.cs" />
<Compile Include="TestObjects\PublicParametizedConstructorTestClass.cs" />
<Compile Include="TestObjects\PublicParametizedConstructorWithNonPropertyParameterTestClass.cs" />
<Compile Include="TestObjects\PublicParametizedConstructorWithPropertyNameConflict.cs" />
<Compile Include="TestObjects\SearchResult.cs" />
<Compile Include="TestObjects\StructTest.cs" />
<Compile Include="TestObjects\WagePerson.cs" />
<Compile Include="TestObjects\PropertyCase.cs" />
<Compile Include="TestObjects\RequestOnly.cs" />
<Compile Include="TestObjects\RoleTransfer.cs" />
<Compile Include="TestObjects\SetOnlyPropertyClass2.cs" />
<Compile Include="TestObjects\SubKlass.cs" />
<Compile Include="TestObjects\SuperKlass.cs" />
<Compile Include="TestObjects\VersionKeyedCollection.cs" />
<Compile Include="TestObjects\AbstractGenericBase.cs" />
<Compile Include="TestObjects\ArgumentConverterPrecedenceClassConverter.cs" />
<Compile Include="TestObjects\BadJsonPropertyClass.cs" />
<Compile Include="TestObjects\CircularReferenceClass.cs" />
<Compile Include="TestObjects\ClassAndMemberConverterClass.cs" />
<Compile Include="TestObjects\ClassConverterPrecedenceClassConverter.cs" />
<Compile Include="TestObjects\ConstructorCaseSensitivityClass.cs" />
<Compile Include="TestObjects\ConverterPrecedenceClass.cs" />
<Compile Include="TestObjects\ConverterPrecedenceClassConverter.cs" />
<Compile Include="TestObjects\CircularReferenceWithIdClass.cs" />
<Compile Include="TestObjects\EmployeeReference.cs" />
<Compile Include="TestObjects\JsonPropertyWithHandlingValues.cs" />
<Compile Include="TestObjects\DefaultValueAttributeTestClass.cs" />
<Compile Include="TestObjects\DoubleClass.cs" />
<Compile Include="TestObjects\GenericImpl.cs" />
<Compile Include="TestObjects\GenericListAndDictionaryInterfaceProperties.cs" />
<Compile Include="TestObjects\GetOnlyPropertyClass.cs" />
<Compile Include="TestObjects\IncompatibleJsonAttributeClass.cs" />
<Compile Include="TestObjects\Invoice.cs" />
<Compile Include="TestObjects\JsonIgnoreAttributeTestClass.cs" />
<Compile Include="TestObjects\MemberConverterPrecedenceClassConverter.cs" />
<Compile Include="TestObjects\MethodExecutorObject.cs" />
<Compile Include="TestObjects\JaggedArray.cs" />
<Compile Include="TestObjects\MyClass.cs" />
<Compile Include="TestObjects\Name.cs" />
<Compile Include="TestObjects\PersonRaw.cs" />
<Compile Include="TestObjects\PhoneNumber.cs" />
<Compile Include="TestObjects\PrivateMembersClass.cs" />
<Compile Include="TestObjects\RequiredMembersClass.cs" />
<Compile Include="TestObjects\SerializationEventTestDictionary.cs" />
<Compile Include="TestObjects\SerializationEventTestList.cs" />
<Compile Include="TestObjects\SerializationEventTestObject.cs" />
<Compile Include="TestObjects\SerializationEventTestObjectWithConstructor.cs" />
<Compile Include="TestObjects\SetOnlyPropertyClass.cs" />
<Compile Include="TestObjects\Article.cs" />
<Compile Include="TestObjects\ArticleCollection.cs" />
<Compile Include="TestObjects\ClassWithArray.cs" />
<Compile Include="TestObjects\ClassWithGuid.cs" />
<Compile Include="TestObjects\ConverableMembers.cs" />
<Compile Include="TestObjects\JsonIgnoreAttributeOnClassTestClass.cs" />
<Compile Include="Linq\JConstructorTests.cs" />
<Compile Include="Linq\JPropertyTests.cs" />
<Compile Include="TestObjects\MemberConverterClass.cs" />
<Compile Include="TestObjects\Product.cs" />
<Compile Include="TestObjects\ProductCollection.cs" />
<Compile Include="TestObjects\ProductShort.cs" />
<Compile Include="TestObjects\Shortie.cs" />
<Compile Include="TestObjects\Store.cs" />
<Compile Include="TestObjects\StoreColor.cs" />
<Compile Include="TestObjects\Person.cs" />
<Compile Include="Schema\JsonSchemaBuilderTests.cs" />
<Compile Include="Schema\JsonSchemaGeneratorTests.cs" />
<Compile Include="Schema\JsonSchemaTests.cs" />
<Compile Include="TestObjects\NullableDateTimeTestClass.cs" />
<Compile Include="TestObjects\DateTimeTestClass.cs" />
<Compile Include="Converters\IsoDateTimeConverterTests.cs" />
<Compile Include="JsonConvertTest.cs" />
<Compile Include="Converters\JavaScriptDateTimeConverterTests.cs" />
<Compile Include="Serialization\JsonSerializerTest.cs" />
<Compile Include="JsonTextReaderTest.cs" />
<Compile Include="JsonTextWriterTest.cs" />
<Compile Include="Linq\JTokenReaderTest.cs" />
<Compile Include="Linq\JTokenWriterTest.cs" />
<Compile Include="Linq\JArrayTests.cs" />
<Compile Include="Linq\JObjectTests.cs" />
<Compile Include="Linq\JTokenEqualityComparerTests.cs" />
<Compile Include="Linq\JTokenTests.cs" />
<Compile Include="Linq\JValueTests.cs" />
<Compile Include="Linq\LinqToJsonTest.cs" />
<Compile Include="PerformanceTests.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SilverlightTests.cs" />
<Compile Include="TestFixtureBase.cs" />
<Compile Include="Converters\XmlNodeConverterTest.cs" />
<Compile Include="TestObjects\TypeClass.cs" />
<Compile Include="TestObjects\TypedSubHashtable.cs" />
<Compile Include="TestObjects\UserNullable.cs" />
<Compile Include="Utilities\DynamicReflectionDelegateFactoryTests.cs" />
<Compile Include="Utilities\ReflectionUtilsTests.cs" />
</ItemGroup>
<ItemGroup>
<Service Include="{3259AA49-8AA1-44D3-9025-A0B520596A8C}" />
</ItemGroup>
<ItemGroup>
<EntityDeploy Include="FileSystemEntityModel.edmx">
<Generator>EntityModelCodeGenerator</Generator>
<LastGenOutput>FileSystemEntityModel.Designer.cs</LastGenOutput>
</EntityDeploy>
</ItemGroup>
<ItemGroup>
<Content Include="bunny_pancake.jpg">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="PoisonText.txt">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
<Install>false</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Windows.Installer.3.1">
<Visible>False</Visible>
<ProductName>Windows Installer 3.1</ProductName>
<Install>true</Install>
</BootstrapperPackage>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Newtonsoft.Json\Newtonsoft.Json.Portable.csproj">
<Project>{959F7F85-C98B-4876-971A-9036224578E4}</Project>
<Name>Newtonsoft.Json.Portable</Name>
<Aliases>global,NewtonsoftJson</Aliases>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
@@ -1,4 +1,4 @@
#if !SILVERLIGHT && !PocketPC && !NET20 && !NET35 && !NETFX_CORE
#if !(SILVERLIGHT || PocketPC || NET20 || NET35 || NETFX_CORE || PORTABLE)
using System;
using System.Collections.Generic;
using System.Globalization;
@@ -40,8 +40,8 @@ namespace Newtonsoft.Json.Tests
[TestFixture]
public class PerformanceTests : TestFixtureBase
{
//private const int Iterations = 100;
private const int Iterations = 5000;
private const int Iterations = 100;
//private const int Iterations = 5000;
#region Data
@@ -72,5 +72,5 @@ using System.Security;
// by using the '*' as shown below:
[assembly: AssemblyVersion("4.5.0.0")]
#if !PocketPC
[assembly: AssemblyFileVersion("4.5.3.14817")]
[assembly: AssemblyFileVersion("4.5.3.14818")]
#endif
@@ -202,7 +202,7 @@ namespace Newtonsoft.Json.Tests.Schema
#if !NET20 && !PocketPC
GenerateSchemaAndSerializeFromType(new NullableDateTimeTestClass());
#endif
#if !(SILVERLIGHT || NETFX_CORE)
#if !(SILVERLIGHT || NETFX_CORE || PORTABLE)
GenerateSchemaAndSerializeFromType(new DataSet());
#endif
GenerateSchemaAndSerializeFromType(new object());
@@ -210,7 +210,7 @@ namespace Newtonsoft.Json.Tests.Schema
GenerateSchemaAndSerializeFromType("Hi");
GenerateSchemaAndSerializeFromType(new DateTime(2000, 12, 29, 23, 59, 0, DateTimeKind.Utc));
GenerateSchemaAndSerializeFromType(TimeSpan.FromTicks(1000000));
#if !NETFX_CORE
#if !(NETFX_CORE || PORTABLE)
GenerateSchemaAndSerializeFromType(DBNull.Value);
#endif
GenerateSchemaAndSerializeFromType(new JsonPropertyWithHandlingValues());
@@ -90,7 +90,7 @@ namespace Newtonsoft.Json.Tests.Schema
Assert.IsTrue(o.IsValid(schema));
}
#if !PocketPC && !NETFX_CORE
#if !(NETFX_CORE || PORTABLE)
[Test]
public void Generate_DefaultValueAttributeTestClass()
{
@@ -310,7 +310,7 @@ namespace Newtonsoft.Json.Tests.Schema
Assert.IsTrue(v.IsValid(schema));
}
#if !SILVERLIGHT && !PocketPC && !NETFX_CORE
#if !(SILVERLIGHT || NETFX_CORE || PORTABLE)
[Test]
public void GenerateSchemaForISerializable()
{
@@ -325,7 +325,7 @@ namespace Newtonsoft.Json.Tests.Schema
}
#endif
#if !NETFX_CORE
#if !(NETFX_CORE || PORTABLE)
[Test]
public void GenerateSchemaForDBNull()
{
@@ -370,7 +370,7 @@ namespace Newtonsoft.Json.Tests.Schema
generator.UndefinedSchemaIdHandling = UndefinedSchemaIdHandling.UseTypeName;
generator.ContractResolver = new CustomDirectoryInfoMapper
{
#if !(SILVERLIGHT || NETFX_CORE)
#if !(SILVERLIGHT || NETFX_CORE || PORTABLE)
IgnoreSerializableAttribute = true
#endif
};
@@ -454,7 +454,7 @@ namespace Newtonsoft.Json.Tests.Schema
serializer.Converters.Add(new IsoDateTimeConverter());
serializer.ContractResolver = new CustomDirectoryInfoMapper
{
#if !(SILVERLIGHT || NETFX_CORE)
#if !(SILVERLIGHT || NETFX_CORE || PORTABLE)
IgnoreSerializableInterface = true
#endif
};
@@ -474,7 +474,7 @@ namespace Newtonsoft.Json.Tests.Schema
generator.UndefinedSchemaIdHandling = UndefinedSchemaIdHandling.UseTypeName;
generator.ContractResolver = new CamelCasePropertyNamesContractResolver()
{
#if !(SILVERLIGHT || NETFX_CORE)
#if !(SILVERLIGHT || NETFX_CORE || PORTABLE)
IgnoreSerializableAttribute = true
#endif
};
@@ -519,7 +519,7 @@ namespace Newtonsoft.Json.Tests.Schema
}", json);
}
#if !(SILVERLIGHT || NETFX_CORE)
#if !(SILVERLIGHT || NETFX_CORE || PORTABLE)
[Test]
public void GenerateSchemaSerializable()
{
@@ -177,7 +177,7 @@ namespace Newtonsoft.Json.Tests.Serialization
}", json);
}
#if !(NET35 || NET20 || WINDOWS_PHONE)
#if !(NET35 || NET20 || WINDOWS_PHONE || PORTABLE)
[Test]
public void DynamicCamelCasePropertyNames()
{
@@ -1,4 +1,4 @@
#if !(NET35 || NET20 || WINDOWS_PHONE)
#if !(NET35 || NET20 || WINDOWS_PHONE || PORTABLE)
using System;
using System.Collections;
using System.Collections.Generic;
@@ -23,7 +23,7 @@
// OTHER DEALINGS IN THE SOFTWARE.
#endregion
#if !(NET35 || NET20 || SILVERLIGHT || NETFX_CORE)
#if !(NET35 || NET20 || SILVERLIGHT || NETFX_CORE || PORTABLE)
using System;
using System.Collections.Generic;
using System.Data;
@@ -688,7 +688,7 @@ keyword such as type of business.""
string json = JsonConvert.SerializeObject(new ConverableMembers(), Formatting.Indented);
string expected = null;
#if !NETFX_CORE
#if !(NETFX_CORE || PORTABLE)
expected = @"{
""String"": ""string"",
""Int32"": 2147483647,
@@ -728,7 +728,7 @@ keyword such as type of business.""
ConverableMembers c = JsonConvert.DeserializeObject<ConverableMembers>(json);
Assert.AreEqual("string", c.String);
Assert.AreEqual(double.MaxValue, c.Double);
#if !NETFX_CORE
#if !(NETFX_CORE || PORTABLE)
Assert.AreEqual(DBNull.Value, c.DBNull);
#endif
}
@@ -1471,7 +1471,7 @@ keyword such as type of business.""
Assert.AreEqual("titleId", n.FidOrder[n.FidOrder.Count - 1]);
}
#if !SILVERLIGHT && !PocketPC && !NET20 && !NETFX_CORE
#if !(SILVERLIGHT || NET20 || NETFX_CORE || PORTABLE)
[MetadataType(typeof (OptInClassMetadata))]
public class OptInClass
{
@@ -2036,7 +2036,7 @@ To force JSON objects to deserialize add the JsonObjectAttribute to the type. Li
{
ContractResolver = new DefaultContractResolver
{
#if !(SILVERLIGHT || NETFX_CORE)
#if !(SILVERLIGHT || NETFX_CORE || PORTABLE)
IgnoreSerializableAttribute = true
#endif
}
@@ -2054,11 +2054,11 @@ To force JSON objects to deserialize add the JsonObjectAttribute to the type. Li
JsonConvert.DeserializeObject<MemoryStream>("{ReadTimeout:0}", new JsonSerializerSettings
{
ContractResolver = new DefaultContractResolver
{
#if !(SILVERLIGHT || NETFX_CORE)
{
#if !(SILVERLIGHT || NETFX_CORE || PORTABLE)
IgnoreSerializableAttribute = true
#endif
}
}
});
}
@@ -2073,11 +2073,11 @@ To force JSON objects to deserialize add the JsonObjectAttribute to the type. Li
JsonConvert.DeserializeObject<MemoryStream>("{ReadTimeout:''}", new JsonSerializerSettings
{
ContractResolver = new DefaultContractResolver
{
#if !(SILVERLIGHT || NETFX_CORE)
{
#if !(SILVERLIGHT || NETFX_CORE || PORTABLE)
IgnoreSerializableAttribute = true
#endif
}
}
});
}
@@ -2092,11 +2092,11 @@ To force JSON objects to deserialize add the JsonObjectAttribute to the type. Li
JsonConvert.DeserializeObject<MemoryStream>("{ReadTimeout:null}", new JsonSerializerSettings
{
ContractResolver = new DefaultContractResolver
{
#if !(SILVERLIGHT || NETFX_CORE)
{
#if !(SILVERLIGHT || NETFX_CORE || PORTABLE)
IgnoreSerializableAttribute = true
#endif
}
}
});
}
@@ -2751,7 +2751,7 @@ To force JSON objects to deserialize add the JsonObjectAttribute to the type. Li
Assert.AreEqual("value", newModelStateDictionary["key"]);
}
#if !SILVERLIGHT && !PocketPC && !NETFX_CORE
#if !(SILVERLIGHT || NETFX_CORE || PORTABLE)
public class ISerializableTestObject : ISerializable
{
internal string _stringValue;
@@ -3243,7 +3243,7 @@ To fix this error either change the environment to be fully trusted, change the
}
#endif
#if !NET20 && !SILVERLIGHT
#if !(NET20 || SILVERLIGHT || PORTABLE)
[Test]
public void SerializeDeserializeXNodeProperties()
{
@@ -3274,7 +3274,7 @@ To fix this error either change the environment to be fully trusted, change the
}
#endif
#if !SILVERLIGHT && !NETFX_CORE
#if !(SILVERLIGHT || NETFX_CORE || PORTABLE)
[Test]
public void SerializeDeserializeXmlNodeProperties()
{
@@ -4150,7 +4150,7 @@ To fix this error either change the environment to be fully trusted, change the
}", json);
}
#if !(NET35 || NET20 || WINDOWS_PHONE)
#if !(NET35 || NET20 || WINDOWS_PHONE || PORTABLE)
[Test]
public void SerializeExpandoObject()
{
@@ -5118,7 +5118,7 @@ To fix this error either change the environment to be fully trusted, change the
}
}
#if !(SILVERLIGHT || WINDOWS_PHONE || NETFX_CORE)
#if !(SILVERLIGHT || WINDOWS_PHONE || NETFX_CORE || PORTABLE)
[Test]
public void SerializeException1()
{
@@ -5248,7 +5248,7 @@ To fix this error either change the environment to be fully trusted, change the
}
}
#if !(NET35 || NET20 || SILVERLIGHT || WINDOWS_PHONE)
#if !(NET35 || NET20 || SILVERLIGHT || WINDOWS_PHONE || PORTABLE)
[Test]
public void DeserializeConcurrentDictionary()
{
@@ -5845,7 +5845,7 @@ Parameter name: value"
Converters = { new MetroStringConverter() },
Formatting = Formatting.Indented
});
Assert.AreEqual(metroJson, @"{
Assert.AreEqual(@"{
"":::NAME:::"": "":::APPLE:::"",
"":::EXPIRYDATE:::"": ""2012-04-01T00:00:00"",
"":::PRICE:::"": 3.99,
@@ -5854,7 +5854,7 @@ Parameter name: value"
"":::MEDIUM:::"",
"":::LARGE:::""
]
}");
}", metroJson);
//{
// ":::NAME:::": ":::APPLE:::",
// ":::EXPIRYDATE:::": "2012-04-01T00:00:00",
@@ -5864,11 +5864,6 @@ Parameter name: value"
Color[] colors = new []{ Color.Blue, Color.Red, Color.Yellow, Color.Green, Color.Black, Color.Brown };
string json1 = JsonConvert.SerializeObject(colors);
//[":::GRAY:::", ":::GRAY:::", ":::GRAY:::", ":::GRAY:::", ":::BLACK:::", ":::GRAY:::"]
Assert.AreEqual(json1, @"[""Blue"",""Red"",""Yellow"",""Green"",""Black"",""Brown""]");
string json2 = JsonConvert.SerializeObject(colors, new JsonSerializerSettings
{
ContractResolver = new MetroPropertyNameResolver(),
@@ -5876,14 +5871,14 @@ Parameter name: value"
Formatting = Formatting.Indented
});
Assert.AreEqual(json2, @"[
Assert.AreEqual(@"[
"":::GRAY:::"",
"":::GRAY:::"",
"":::GRAY:::"",
"":::GRAY:::"",
"":::BLACK:::"",
"":::GRAY:::""
]");
]", json2);
}
public class MetroStringConverter : JsonConverter
@@ -5933,6 +5928,32 @@ Parameter name: value"
}
}
#endif
private class FooBar
{
public DateTimeOffset Foo { get; set; }
}
[Test]
public void TokenFromBson()
{
MemoryStream ms = new MemoryStream();
BsonWriter writer = new BsonWriter(ms);
writer.WriteStartArray();
writer.WriteValue("2000-01-02T03:04:05+06:00");
writer.WriteEndArray();
byte[] data = ms.ToArray();
BsonReader reader = new BsonReader(new MemoryStream(data))
{
ReadRootValueAsArray = true
};
JArray a = (JArray)JArray.ReadFrom(reader);
JValue v = (JValue)a[0];
Console.WriteLine(v.Value.GetType());
Console.WriteLine(a.ToString());
}
}
public class PersonWithPrivateConstructor
@@ -23,6 +23,10 @@
// OTHER DEALINGS IN THE SOFTWARE.
#endregion
#if PORTABLE
extern alias NewtonsoftJson;
using FormatterAssemblyStyle = NewtonsoftJson::System.Runtime.Serialization.Formatters.FormatterAssemblyStyle;
#endif
using System;
using System.Collections;
using System.Collections.Generic;
@@ -135,7 +139,7 @@ namespace Newtonsoft.Json.Tests.Serialization
Assert.AreEqual("Name!", ((EmployeeReference)employee).Name);
}
#if !SILVERLIGHT && !PocketPC && !NETFX_CORE
#if !(SILVERLIGHT || NETFX_CORE || PORTABLE)
[Test]
public void DeserializeTypeNameFromGacAssembly()
{
@@ -969,7 +973,7 @@ namespace Newtonsoft.Json.Tests.Serialization
Binder = new MetroBinder(),
ContractResolver = new DefaultContractResolver
{
#if !(SILVERLIGHT || NETFX_CORE)
#if !(SILVERLIGHT || NETFX_CORE || PORTABLE)
IgnoreSerializableAttribute = true
#endif
}
@@ -34,7 +34,7 @@ namespace Newtonsoft.Json.Tests.Serialization
nonSerializedField = "Error"
};
#if !(SILVERLIGHT || NETFX_CORE || NET20)
#if !(SILVERLIGHT || NETFX_CORE || NET20 || PORTABLE)
MemoryStream ms = new MemoryStream();
DataContractJsonSerializer dataContractJsonSerializer = new DataContractJsonSerializer(typeof(SerializableType));
dataContractJsonSerializer.WriteObject(ms, serializableType);
@@ -50,7 +50,7 @@ namespace Newtonsoft.Json.Tests.Serialization
{
ContractResolver = new DefaultContractResolver
{
#if !(SILVERLIGHT || NETFX_CORE)
#if !(SILVERLIGHT || NETFX_CORE || PORTABLE)
IgnoreSerializableAttribute = false
#endif
}
@@ -59,7 +59,7 @@ namespace Newtonsoft.Json.Tests.Serialization
Assert.AreEqual(expected, json);
}
#if !(SILVERLIGHT || NETFX_CORE)
#if !(SILVERLIGHT || NETFX_CORE || PORTABLE)
[Test]
public void SerializeInheritedType()
{
@@ -89,7 +89,7 @@ namespace Newtonsoft.Json.Tests.Serialization
}
}
#if !(SILVERLIGHT || NETFX_CORE)
#if !(SILVERLIGHT || NETFX_CORE || PORTABLE)
[Serializable]
#else
[JsonObject(MemberSerialization.Fields)]
@@ -119,7 +119,7 @@ namespace Newtonsoft.Json.Tests.Serialization
}
}
#if !(SILVERLIGHT || NETFX_CORE)
#if !(SILVERLIGHT || NETFX_CORE || PORTABLE)
[NonSerialized]
#else
[JsonIgnore]
@@ -41,7 +41,7 @@ namespace Newtonsoft.Json.Tests.TestObjects
public ulong ULong = long.MaxValue;
public double Double = double.MaxValue;
public float Float = float.MaxValue;
#if !NETFX_CORE
#if !(NETFX_CORE || PORTABLE)
public DBNull DBNull = DBNull.Value;
#endif
public bool Bool = true;
@@ -23,7 +23,7 @@
// OTHER DEALINGS IN THE SOFTWARE.
#endregion
#if !PocketPC && !SILVERLIGHT
#if !(SILVERLIGHT || PORTABLE)
using System;
using System.Reflection;
#if !NETFX_CORE
@@ -1,4 +1,8 @@
using System;
#if PORTABLE
extern alias NewtonsoftJson;
using FormatterAssemblyStyle = NewtonsoftJson::System.Runtime.Serialization.Formatters.FormatterAssemblyStyle;
#endif
using System;
using System.Collections.Generic;
using System.Runtime.Serialization.Formatters;
#if !NETFX_CORE
+1 -1
View File
@@ -29,7 +29,7 @@ namespace Newtonsoft.Json.Bson
public void Close()
{
#if !NETFX_CORE
#if !(NETFX_CORE || PORTABLE)
_writer.Close();
#else
_writer.Dispose();
+1 -1
View File
@@ -295,7 +295,7 @@ namespace Newtonsoft.Json.Bson
base.Close();
if (CloseInput && _reader != null)
#if !NETFX_CORE
#if !(NETFX_CORE || PORTABLE)
_reader.Close();
#else
_reader.Dispose();
+1 -1
View File
@@ -357,7 +357,7 @@ namespace Newtonsoft.Json.Bson
{
base.WriteValue(value);
string s = null;
#if !NETFX_CORE
#if !(NETFX_CORE || PORTABLE)
s = value.ToString(CultureInfo.InvariantCulture);
#else
s = value.ToString();
@@ -23,17 +23,16 @@
// OTHER DEALINGS IN THE SOFTWARE.
#endregion
#if !(SILVERLIGHT || NETFX_CORE || PORTABLE)
using System;
#if !SILVERLIGHT && !NETFX_CORE
using System.Data.SqlTypes;
#endif
using System.Globalization;
using Newtonsoft.Json.Utilities;
using System.Collections.Generic;
namespace Newtonsoft.Json.Converters
{
#if !SILVERLIGHT && !PocketPC && !NET20
#if !NET20
internal interface IBinary
{
byte[] ToArray();
@@ -45,7 +44,7 @@ namespace Newtonsoft.Json.Converters
/// </summary>
public class BinaryConverter : JsonConverter
{
#if !SILVERLIGHT && !PocketPC && !NET20
#if !NET20
private const string BinaryTypeName = "System.Data.Linq.Binary";
#endif
@@ -70,17 +69,16 @@ namespace Newtonsoft.Json.Converters
private byte[] GetByteArray(object value)
{
#if !SILVERLIGHT && !PocketPC && !NET20 && !NETFX_CORE
#if !(NET20)
if (value.GetType().AssignableToTypeName(BinaryTypeName))
{
IBinary binary = DynamicWrapper.CreateWrapper<IBinary>(value);
return binary.ToArray();
}
#endif
#if !SILVERLIGHT && !NETFX_CORE
if (value is SqlBinary)
return ((SqlBinary) value).Value;
#endif
throw new Exception("Unexpected value type when writing binary: {0}".FormatWith(CultureInfo.InvariantCulture, value.GetType()));
}
@@ -125,14 +123,14 @@ namespace Newtonsoft.Json.Converters
}
#if !SILVERLIGHT && !PocketPC && !NET20
#if !NET20
if (t.AssignableToTypeName(BinaryTypeName))
return Activator.CreateInstance(t, data);
#endif
#if !SILVERLIGHT && !NETFX_CORE
if (t == typeof(SqlBinary))
return new SqlBinary(data);
#endif
throw new Exception("Unexpected object type when writing binary: {0}".FormatWith(CultureInfo.InvariantCulture, objectType));
}
@@ -169,15 +167,16 @@ namespace Newtonsoft.Json.Converters
/// </returns>
public override bool CanConvert(Type objectType)
{
#if !SILVERLIGHT && !PocketPC && !NET20
#if !NET20
if (objectType.AssignableToTypeName(BinaryTypeName))
return true;
#endif
#if !SILVERLIGHT && !NETFX_CORE
if (objectType == typeof(SqlBinary) || objectType == typeof(SqlBinary?))
return true;
#endif
return false;
}
}
}
}
#endif
@@ -23,7 +23,7 @@
// OTHER DEALINGS IN THE SOFTWARE.
#endregion
#if !(SILVERLIGHT || NETFX_CORE)
#if !(SILVERLIGHT || NETFX_CORE || PORTABLE)
using System;
using System.Data;
using Newtonsoft.Json.Serialization;
@@ -23,7 +23,7 @@
// OTHER DEALINGS IN THE SOFTWARE.
#endregion
#if !SILVERLIGHT && !NETFX_CORE
#if !(SILVERLIGHT || NETFX_CORE || PORTABLE)
using System;
using System.Data;
using Newtonsoft.Json.Serialization;
@@ -23,7 +23,7 @@
// OTHER DEALINGS IN THE SOFTWARE.
#endregion
#if !PocketPC && !SILVERLIGHT && !NET20 && !NETFX_CORE
#if !(SILVERLIGHT || NET20 || NETFX_CORE || PORTABLE)
using System;
using Newtonsoft.Json.Serialization;
using System.Globalization;
@@ -1,4 +1,4 @@
#if !(NET35 || NET20 || WINDOWS_PHONE)
#if !(NET35 || NET20 || WINDOWS_PHONE || PORTABLE)
using System;
using System.Collections.Generic;
@@ -23,7 +23,7 @@
// OTHER DEALINGS IN THE SOFTWARE.
#endregion
#if (!SILVERLIGHT || WINDOWS_PHONE)
#if (!(SILVERLIGHT || PORTABLE) || WINDOWS_PHONE)
using System;
using System.Collections.Generic;
using System.Globalization;
@@ -1,4 +1,4 @@
#if SILVERLIGHT || PocketPC || NETFX_CORE
#if SILVERLIGHT || PocketPC || NETFX_CORE || PORTABLE
namespace System.Runtime.Serialization.Formatters
{
/// <summary>
+10 -10
View File
@@ -26,14 +26,14 @@
using System;
using System.IO;
using System.Globalization;
#if !(NET20 || NET35 || SILVERLIGHT)
#if !(NET20 || NET35 || SILVERLIGHT || PORTABLE)
using System.Threading.Tasks;
#endif
using Newtonsoft.Json.Utilities;
using System.Xml;
using Newtonsoft.Json.Converters;
using System.Text;
#if !NET20 && (!SILVERLIGHT || WINDOWS_PHONE)
#if !NET20 && (!SILVERLIGHT || WINDOWS_PHONE) && !PORTABLE
using System.Xml.Linq;
#endif
#if NETFX_CORE
@@ -485,7 +485,7 @@ namespace Newtonsoft.Json
{
string text = null;
#if !NETFX_CORE
#if !(NETFX_CORE || PORTABLE)
text = value.ToString("D", CultureInfo.InvariantCulture);
#else
text = value.ToString("D");
@@ -584,7 +584,7 @@ namespace Newtonsoft.Json
return ToString(convertible.ToDateTime(CultureInfo.InvariantCulture));
case TypeCode.Decimal:
return ToString(convertible.ToDecimal(CultureInfo.InvariantCulture));
#if !NETFX_CORE
#if !(NETFX_CORE || PORTABLE)
case TypeCode.DBNull:
return Null;
#endif
@@ -631,7 +631,7 @@ namespace Newtonsoft.Json
case TypeCode.Double:
case TypeCode.DateTime:
case TypeCode.Decimal:
#if !NETFX_CORE
#if !(NETFX_CORE || PORTABLE)
case TypeCode.DBNull:
#endif
return true;
@@ -752,7 +752,7 @@ namespace Newtonsoft.Json
return sw.ToString();
}
#if !(NET20 || NET35 || SILVERLIGHT)
#if !(NET20 || NET35 || SILVERLIGHT || PORTABLE)
/// <summary>
/// Asynchronously serializes the specified object to a JSON string using a collection of <see cref="JsonConverter"/>.
/// </summary>
@@ -931,7 +931,7 @@ namespace Newtonsoft.Json
return deserializedValue;
}
#if !(NET20 || NET35 || SILVERLIGHT)
#if !(NET20 || NET35 || SILVERLIGHT || PORTABLE)
/// <summary>
/// Asynchronously deserializes the JSON to the specified .NET type.
/// </summary>
@@ -1026,7 +1026,7 @@ namespace Newtonsoft.Json
}
}
#if !(NET20 || NET35 || SILVERLIGHT)
#if !(NET20 || NET35 || SILVERLIGHT || PORTABLE)
/// <summary>
/// Asynchronously populates the object with values from the JSON string.
/// </summary>
@@ -1045,7 +1045,7 @@ namespace Newtonsoft.Json
}
#endif
#if !(SILVERLIGHT || NETFX_CORE)
#if !(SILVERLIGHT || PORTABLE || NETFX_CORE)
/// <summary>
/// Serializes the XML node to a JSON string.
/// </summary>
@@ -1124,7 +1124,7 @@ namespace Newtonsoft.Json
}
#endif
#if !NET20 && (!SILVERLIGHT || WINDOWS_PHONE)
#if !NET20 && (!(SILVERLIGHT || PORTABLE) || WINDOWS_PHONE)
/// <summary>
/// Serializes the <see cref="XNode"/> to a JSON string.
/// </summary>
+2 -2
View File
@@ -31,7 +31,7 @@ namespace Newtonsoft.Json
/// <summary>
/// The exception thrown when an error occurs while reading Json text.
/// </summary>
#if !(SILVERLIGHT || WINDOWS_PHONE || NETFX_CORE)
#if !(SILVERLIGHT || WINDOWS_PHONE || NETFX_CORE || PORTABLE)
[Serializable]
#endif
public class JsonReaderException : Exception
@@ -83,7 +83,7 @@ namespace Newtonsoft.Json
{
}
#if !(WINDOWS_PHONE || SILVERLIGHT || NETFX_CORE)
#if !(WINDOWS_PHONE || SILVERLIGHT || NETFX_CORE || PORTABLE)
/// <summary>
/// Initializes a new instance of the <see cref="JsonReaderException"/> class.
/// </summary>
@@ -33,7 +33,7 @@ namespace Newtonsoft.Json
/// <summary>
/// The exception thrown when an error occurs during Json serialization or deserialization.
/// </summary>
#if !(SILVERLIGHT || WINDOWS_PHONE || NETFX_CORE)
#if !(SILVERLIGHT || WINDOWS_PHONE || NETFX_CORE || PORTABLE)
[Serializable]
#endif
public class JsonSerializationException : Exception
@@ -66,7 +66,7 @@ namespace Newtonsoft.Json
{
}
#if !(WINDOWS_PHONE || SILVERLIGHT || NETFX_CORE)
#if !(WINDOWS_PHONE || SILVERLIGHT || NETFX_CORE || PORTABLE)
/// <summary>
/// Initializes a new instance of the <see cref="JsonSerializationException"/> class.
/// </summary>
+1 -1
View File
@@ -1579,7 +1579,7 @@ namespace Newtonsoft.Json
base.Close();
if (CloseInput && _reader != null)
#if !NETFX_CORE
#if !(NETFX_CORE || PORTABLE)
_reader.Close();
#else
_reader.Dispose();
+1 -1
View File
@@ -136,7 +136,7 @@ namespace Newtonsoft.Json
base.Close();
if (CloseOutput && _writer != null)
#if !NETFX_CORE
#if !(NETFX_CORE || PORTABLE)
_writer.Close();
#else
_writer.Dispose();
+1 -1
View File
@@ -1212,7 +1212,7 @@ namespace Newtonsoft.Json
case TypeCode.Decimal:
WriteValue(convertible.ToDecimal(CultureInfo.InvariantCulture));
return;
#if !NETFX_CORE
#if !(NETFX_CORE || PORTABLE)
case TypeCode.DBNull:
WriteNull();
return;
+2 -2
View File
@@ -33,7 +33,7 @@ namespace Newtonsoft.Json
/// <summary>
/// The exception thrown when an error occurs while reading Json text.
/// </summary>
#if !(SILVERLIGHT || WINDOWS_PHONE || NETFX_CORE)
#if !(SILVERLIGHT || WINDOWS_PHONE || NETFX_CORE || PORTABLE)
[Serializable]
#endif
public class JsonWriterException : Exception
@@ -66,7 +66,7 @@ namespace Newtonsoft.Json
{
}
#if !(WINDOWS_PHONE || SILVERLIGHT || NETFX_CORE)
#if !(WINDOWS_PHONE || SILVERLIGHT || NETFX_CORE || PORTABLE)
/// <summary>
/// Initializes a new instance of the <see cref="JsonWriterException"/> class.
/// </summary>
+1 -1
View File
@@ -7,7 +7,7 @@ namespace Newtonsoft.Json.Linq
/// </summary>
/// <typeparam name="T">The type of token</typeparam>
public interface IJEnumerable<
#if !(NET20 || NET35 || SILVERLIGHT)
#if !(NET20 || NET35 || SILVERLIGHT || PORTABLE)
out
#endif
T> : IEnumerable<T> where T : JToken
+21 -18
View File
@@ -25,7 +25,9 @@
using System;
using System.Collections.Generic;
#if !PORTABLE
using System.Collections.Specialized;
#endif
using System.Threading;
using Newtonsoft.Json.Utilities;
using System.Collections;
@@ -43,16 +45,17 @@ namespace Newtonsoft.Json.Linq
/// Represents a token that can contain other tokens.
/// </summary>
public abstract class JContainer : JToken, IList<JToken>
#if !(SILVERLIGHT || NETFX_CORE)
#if !(SILVERLIGHT || NETFX_CORE || PORTABLE)
, ITypedList, IBindingList
#else
, IList, INotifyCollectionChanged
#elif !PORTABLE
, INotifyCollectionChanged
#endif
#if !(SILVERLIGHT || NET20 || NET35 || NETFX_CORE)
, IList
#if !(SILVERLIGHT || NET20 || NET35 || NETFX_CORE || PORTABLE)
, INotifyCollectionChanged
#endif
{
#if !SILVERLIGHT && !NETFX_CORE
#if !(SILVERLIGHT || NETFX_CORE || PORTABLE)
/// <summary>
/// Occurs when the list changes or an item in the list changes.
/// </summary>
@@ -63,7 +66,7 @@ namespace Newtonsoft.Json.Linq
/// </summary>
public event AddingNewEventHandler AddingNew;
#endif
#if SILVERLIGHT || !(NET20 || NET35)
#if SILVERLIGHT || !(NET20 || NET35 || PORTABLE)
/// <summary>
/// Occurs when the items list of the collection has changed, or the collection is reset.
/// </summary>
@@ -99,7 +102,7 @@ namespace Newtonsoft.Json.Linq
throw new InvalidOperationException("Cannot change {0} during a collection change event.".FormatWith(CultureInfo.InvariantCulture, GetType()));
}
#if !SILVERLIGHT && !NETFX_CORE
#if !(SILVERLIGHT || NETFX_CORE || PORTABLE)
/// <summary>
/// Raises the <see cref="AddingNew"/> event.
/// </summary>
@@ -133,7 +136,7 @@ namespace Newtonsoft.Json.Linq
}
}
#endif
#if SILVERLIGHT || !(NET20 || NET35)
#if SILVERLIGHT || !(NET20 || NET35 || PORTABLE)
/// <summary>
/// Raises the <see cref="CollectionChanged"/> event.
/// </summary>
@@ -326,11 +329,11 @@ namespace Newtonsoft.Json.Linq
ChildrenTokens.Insert(index, item);
#if !SILVERLIGHT && !NETFX_CORE
#if !(SILVERLIGHT || NETFX_CORE || PORTABLE)
if (ListChanged != null)
OnListChanged(new ListChangedEventArgs(ListChangedType.ItemAdded, index));
#endif
#if SILVERLIGHT || !(NET20 || NET35)
#if SILVERLIGHT || !(NET20 || NET35 || PORTABLE)
if (CollectionChanged != null)
OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, item, index));
#endif
@@ -360,10 +363,10 @@ namespace Newtonsoft.Json.Linq
ChildrenTokens.RemoveAt(index);
#if !SILVERLIGHT && !NETFX_CORE
#if !(SILVERLIGHT || NETFX_CORE || PORTABLE)
OnListChanged(new ListChangedEventArgs(ListChangedType.ItemDeleted, index));
#endif
#if SILVERLIGHT || !(NET20 || NET35)
#if SILVERLIGHT || !(NET20 || NET35 || PORTABLE)
OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Remove, item, index));
#endif
}
@@ -422,10 +425,10 @@ namespace Newtonsoft.Json.Linq
existing.Previous = null;
existing.Next = null;
#if !SILVERLIGHT && !NETFX_CORE
#if !(SILVERLIGHT || NETFX_CORE || PORTABLE)
OnListChanged(new ListChangedEventArgs(ListChangedType.ItemChanged, index));
#endif
#if SILVERLIGHT || !(NET20 || NET35)
#if SILVERLIGHT || !(NET20 || NET35 || PORTABLE)
OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Replace, item, existing, index));
#endif
}
@@ -443,10 +446,10 @@ namespace Newtonsoft.Json.Linq
ChildrenTokens.Clear();
#if !SILVERLIGHT && !NETFX_CORE
#if !(SILVERLIGHT || NETFX_CORE || PORTABLE)
OnListChanged(new ListChangedEventArgs(ListChangedType.Reset, -1));
#endif
#if SILVERLIGHT || !(NET20 || NET35)
#if SILVERLIGHT || !(NET20 || NET35 || PORTABLE)
OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset));
#endif
}
@@ -715,7 +718,7 @@ namespace Newtonsoft.Json.Linq
return hashCode;
}
#if !SILVERLIGHT && !NETFX_CORE
#if !(SILVERLIGHT || NETFX_CORE || PORTABLE)
string ITypedList.GetListName(PropertyDescriptor[] listAccessors)
{
return string.Empty;
@@ -894,7 +897,7 @@ namespace Newtonsoft.Json.Linq
#region IBindingList Members
#if !SILVERLIGHT && !NETFX_CORE
#if !(SILVERLIGHT || NETFX_CORE || PORTABLE)
void IBindingList.AddIndex(PropertyDescriptor property)
{
}
+13 -11
View File
@@ -26,9 +26,11 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
#if !PORTABLE
using System.Collections.Specialized;
#endif
using System.ComponentModel;
#if !(NET35 || NET20 || WINDOWS_PHONE)
#if !(NET35 || NET20 || WINDOWS_PHONE || PORTABLE)
using System.Dynamic;
using System.Linq.Expressions;
#endif
@@ -47,10 +49,10 @@ namespace Newtonsoft.Json.Linq
/// Represents a JSON object.
/// </summary>
public class JObject : JContainer, IDictionary<string, JToken>, INotifyPropertyChanged
#if !(PocketPC || SILVERLIGHT || NETFX_CORE)
#if !(SILVERLIGHT || NETFX_CORE || PORTABLE)
, ICustomTypeDescriptor
#endif
#if !(PocketPC || SILVERLIGHT || NET20 || NETFX_CORE)
#if !(SILVERLIGHT || NET20 || NETFX_CORE || PORTABLE)
, INotifyPropertyChanging
#endif
{
@@ -70,7 +72,7 @@ namespace Newtonsoft.Json.Linq
/// </summary>
public event PropertyChangedEventHandler PropertyChanged;
#if !(PocketPC || SILVERLIGHT || NET20 || NETFX_CORE)
#if !(SILVERLIGHT || NET20 || NETFX_CORE || PORTABLE)
/// <summary>
/// Occurs when a property value is changing.
/// </summary>
@@ -153,17 +155,17 @@ namespace Newtonsoft.Json.Linq
internal void InternalPropertyChanged(JProperty childProperty)
{
OnPropertyChanged(childProperty.Name);
#if !SILVERLIGHT && !NETFX_CORE
#if !(SILVERLIGHT || NETFX_CORE || PORTABLE)
OnListChanged(new ListChangedEventArgs(ListChangedType.ItemChanged, IndexOfItem(childProperty)));
#endif
#if SILVERLIGHT || !(NET20 || NET35)
#if SILVERLIGHT || !(NET20 || NET35 || PORTABLE)
OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Replace, childProperty, childProperty, IndexOfItem(childProperty)));
#endif
}
internal void InternalPropertyChanging(JProperty childProperty)
{
#if !PocketPC && !SILVERLIGHT && !NET20 && !NETFX_CORE
#if !(SILVERLIGHT || NET20 || NETFX_CORE || PORTABLE)
OnPropertyChanging(childProperty.Name);
#endif
}
@@ -266,7 +268,7 @@ namespace Newtonsoft.Json.Linq
}
else
{
#if !PocketPC && !SILVERLIGHT && !NET20 && !NETFX_CORE
#if !(SILVERLIGHT || NET20 || NETFX_CORE || PORTABLE)
OnPropertyChanging(propertyName);
#endif
Add(new JProperty(propertyName, value));
@@ -517,7 +519,7 @@ namespace Newtonsoft.Json.Linq
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
#if !PocketPC && !SILVERLIGHT && !NET20 && !NETFX_CORE
#if !(SILVERLIGHT || NETFX_CORE || PORTABLE || NET20)
/// <summary>
/// Raises the <see cref="PropertyChanging"/> event with the provided arguments.
/// </summary>
@@ -529,7 +531,7 @@ namespace Newtonsoft.Json.Linq
}
#endif
#if !PocketPC && !SILVERLIGHT && !NETFX_CORE
#if !(SILVERLIGHT || NETFX_CORE || PORTABLE)
// include custom type descriptor on JObject rather than use a provider because the properties are specific to a type
#region ICustomTypeDescriptor
/// <summary>
@@ -688,7 +690,7 @@ namespace Newtonsoft.Json.Linq
#endregion
#endif
#if !(NET35 || NET20 || WINDOWS_PHONE)
#if !(NET35 || NET20 || WINDOWS_PHONE || PORTABLE)
/// <summary>
/// Returns the <see cref="T:System.Dynamic.DynamicMetaObject"/> responsible for binding operations performed on this object.
/// </summary>
@@ -23,7 +23,7 @@
// OTHER DEALINGS IN THE SOFTWARE.
#endregion
#if !SILVERLIGHT && !NETFX_CORE
#if !(SILVERLIGHT || NETFX_CORE || PORTABLE)
using System;
using System.ComponentModel;
using Newtonsoft.Json.Utilities;
+5 -5
View File
@@ -25,7 +25,7 @@
using System;
using System.Collections.Generic;
#if !(NET35 || NET20 || WINDOWS_PHONE)
#if !(NET35 || NET20 || WINDOWS_PHONE || PORTABLE)
using System.Dynamic;
using System.Linq.Expressions;
#endif
@@ -46,10 +46,10 @@ namespace Newtonsoft.Json.Linq
/// Represents an abstract JSON token.
/// </summary>
public abstract class JToken : IJEnumerable<JToken>, IJsonLineInfo
#if !SILVERLIGHT && !NETFX_CORE
#if !(SILVERLIGHT || NETFX_CORE || PORTABLE)
, ICloneable
#endif
#if !(NET35 || NET20 || WINDOWS_PHONE)
#if !(NET35 || NET20 || WINDOWS_PHONE || PORTABLE)
, IDynamicMetaObjectProvider
#endif
{
@@ -1318,7 +1318,7 @@ namespace Newtonsoft.Json.Linq
return p.Evaluate(this, errorWhenNoMatch);
}
#if !(NET35 || NET20 || WINDOWS_PHONE)
#if !(NET35 || NET20 || WINDOWS_PHONE || PORTABLE)
/// <summary>
/// Returns the <see cref="T:System.Dynamic.DynamicMetaObject"/> responsible for binding operations performed on this object.
/// </summary>
@@ -1344,7 +1344,7 @@ namespace Newtonsoft.Json.Linq
}
#endif
#if !SILVERLIGHT && !NETFX_CORE
#if !(SILVERLIGHT || NETFX_CORE || PORTABLE)
object ICloneable.Clone()
{
return DeepClone();
+1 -1
View File
@@ -302,7 +302,7 @@ namespace Newtonsoft.Json.Linq
{
base.WriteValue(value);
string s = null;
#if !NETFX_CORE
#if !(NETFX_CORE || PORTABLE)
s = value.ToString(CultureInfo.InvariantCulture);
#else
s = value.ToString();
+4 -4
View File
@@ -27,7 +27,7 @@ using System;
using System.Collections.Generic;
using Newtonsoft.Json.Utilities;
using System.Globalization;
#if !(NET35 || NET20 || WINDOWS_PHONE)
#if !(NET35 || NET20 || WINDOWS_PHONE || PORTABLE)
using System.Dynamic;
using System.Linq.Expressions;
#endif
@@ -277,7 +277,7 @@ namespace Newtonsoft.Json.Linq
return d1.CompareTo(d2);
}
#if !(NET35 || NET20 || WINDOWS_PHONE)
#if !(NET35 || NET20 || WINDOWS_PHONE || PORTABLE)
private static bool Operation(ExpressionType operation, object objA, object objB, out object result)
{
if (objA is string || objB is string)
@@ -418,7 +418,7 @@ namespace Newtonsoft.Json.Linq
{
if (value == null)
return JTokenType.Null;
#if !NETFX_CORE
#if !(NETFX_CORE || PORTABLE)
else if (value == DBNull.Value)
return JTokenType.Null;
#endif
@@ -681,7 +681,7 @@ namespace Newtonsoft.Json.Linq
return _value.ToString();
}
#if !(NET35 || NET20 || WINDOWS_PHONE)
#if !(NET35 || NET20 || WINDOWS_PHONE || PORTABLE)
/// <summary>
/// Returns the <see cref="T:System.Dynamic.DynamicMetaObject"/> responsible for binding operations performed on this object.
/// </summary>
@@ -0,0 +1,212 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{959F7F85-C98B-4876-971A-9036224578E4}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Newtonsoft.Json</RootNamespace>
<AssemblyName>Newtonsoft.Json</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkProfile>Profile2</TargetFrameworkProfile>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\Portable\</OutputPath>
<DefineConstants>TRACE;DEBUG;PORTABLE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\Portable\</OutputPath>
<DefineConstants>TRACE;PORTABLE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Net" />
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.ServiceModel" />
<Reference Include="System.Xml" />
<Reference Include="System.Xml.Serialization" />
</ItemGroup>
<ItemGroup>
<Compile Include="Bson\BsonBinaryType.cs" />
<Compile Include="Bson\BsonBinaryWriter.cs" />
<Compile Include="Bson\BsonObjectId.cs" />
<Compile Include="Bson\BsonReader.cs" />
<Compile Include="Bson\BsonToken.cs" />
<Compile Include="Bson\BsonType.cs" />
<Compile Include="Bson\BsonWriter.cs" />
<Compile Include="ConstructorHandling.cs" />
<Compile Include="Converters\BinaryConverter.cs" />
<Compile Include="Converters\BsonObjectIdConverter.cs" />
<Compile Include="Converters\CustomCreationConverter.cs" />
<Compile Include="Converters\DataSetConverter.cs" />
<Compile Include="Converters\DataTableConverter.cs" />
<Compile Include="Converters\DateTimeConverterBase.cs" />
<Compile Include="Converters\EntityKeyMemberConverter.cs" />
<Compile Include="Converters\ExpandoObjectConverter.cs" />
<Compile Include="Converters\IsoDateTimeConverter.cs" />
<Compile Include="Converters\JavaScriptDateTimeConverter.cs" />
<Compile Include="Converters\KeyValuePairConverter.cs" />
<Compile Include="Converters\RegexConverter.cs" />
<Compile Include="Converters\StringEnumConverter.cs" />
<Compile Include="Converters\VersionConverter.cs" />
<Compile Include="Converters\XmlNodeConverter.cs" />
<Compile Include="DateFormatHandling.cs" />
<Compile Include="DateTimeZoneHandling.cs" />
<Compile Include="DefaultValueHandling.cs" />
<Compile Include="FormatterAssemblyStyle.cs" />
<Compile Include="Formatting.cs" />
<Compile Include="IJsonLineInfo.cs" />
<Compile Include="JsonArrayAttribute.cs" />
<Compile Include="JsonConstructorAttribute.cs" />
<Compile Include="JsonContainerAttribute.cs" />
<Compile Include="JsonConvert.cs" />
<Compile Include="JsonConverter.cs" />
<Compile Include="JsonConverterAttribute.cs" />
<Compile Include="JsonConverterCollection.cs" />
<Compile Include="JsonIgnoreAttribute.cs" />
<Compile Include="JsonObjectAttribute.cs" />
<Compile Include="JsonPosition.cs" />
<Compile Include="JsonPropertyAttribute.cs" />
<Compile Include="JsonReader.cs" />
<Compile Include="JsonReaderException.cs" />
<Compile Include="JsonSerializationException.cs" />
<Compile Include="JsonSerializer.cs" />
<Compile Include="JsonSerializerSettings.cs" />
<Compile Include="JsonTextReader.cs" />
<Compile Include="JsonTextWriter.cs" />
<Compile Include="JsonToken.cs" />
<Compile Include="JsonValidatingReader.cs" />
<Compile Include="JsonWriter.cs" />
<Compile Include="JsonWriterException.cs" />
<Compile Include="Linq\Extensions.cs" />
<Compile Include="Linq\IJEnumerable.cs" />
<Compile Include="Linq\JArray.cs" />
<Compile Include="Linq\JConstructor.cs" />
<Compile Include="Linq\JContainer.cs" />
<Compile Include="Linq\JEnumerable.cs" />
<Compile Include="Linq\JObject.cs" />
<Compile Include="Linq\JPath.cs" />
<Compile Include="Linq\JProperty.cs" />
<Compile Include="Linq\JPropertyDescriptor.cs" />
<Compile Include="Linq\JPropertyKeyedCollection.cs" />
<Compile Include="Linq\JRaw.cs" />
<Compile Include="Linq\JToken.cs" />
<Compile Include="Linq\JTokenEqualityComparer.cs" />
<Compile Include="Linq\JTokenReader.cs" />
<Compile Include="Linq\JTokenType.cs" />
<Compile Include="Linq\JTokenWriter.cs" />
<Compile Include="Linq\JValue.cs" />
<Compile Include="MemberSerialization.cs" />
<Compile Include="MissingMemberHandling.cs" />
<Compile Include="NullValueHandling.cs" />
<Compile Include="ObjectCreationHandling.cs" />
<Compile Include="PreserveReferencesHandling.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="ReferenceLoopHandling.cs" />
<Compile Include="Required.cs" />
<Compile Include="Schema\Extensions.cs" />
<Compile Include="Schema\JsonSchema.cs" />
<Compile Include="Schema\JsonSchemaBuilder.cs" />
<Compile Include="Schema\JsonSchemaConstants.cs" />
<Compile Include="Schema\JsonSchemaException.cs" />
<Compile Include="Schema\JsonSchemaGenerator.cs" />
<Compile Include="Schema\JsonSchemaModel.cs" />
<Compile Include="Schema\JsonSchemaModelBuilder.cs" />
<Compile Include="Schema\JsonSchemaNode.cs" />
<Compile Include="Schema\JsonSchemaNodeCollection.cs" />
<Compile Include="Schema\JsonSchemaResolver.cs" />
<Compile Include="Schema\JsonSchemaType.cs" />
<Compile Include="Schema\JsonSchemaWriter.cs" />
<Compile Include="Schema\UndefinedSchemaIdHandling.cs" />
<Compile Include="Schema\ValidationEventArgs.cs" />
<Compile Include="Schema\ValidationEventHandler.cs" />
<Compile Include="SerializationBinder.cs" />
<Compile Include="Serialization\CachedAttributeGetter.cs" />
<Compile Include="Serialization\CamelCasePropertyNamesContractResolver.cs" />
<Compile Include="Serialization\DefaultContractResolver.cs" />
<Compile Include="Serialization\DefaultReferenceResolver.cs" />
<Compile Include="Serialization\DefaultSerializationBinder.cs" />
<Compile Include="Serialization\DynamicValueProvider.cs" />
<Compile Include="Serialization\ErrorContext.cs" />
<Compile Include="Serialization\ErrorEventArgs.cs" />
<Compile Include="Serialization\IContractResolver.cs" />
<Compile Include="Serialization\IReferenceResolver.cs" />
<Compile Include="Serialization\IValueProvider.cs" />
<Compile Include="Serialization\JsonArrayContract.cs" />
<Compile Include="Serialization\JsonContract.cs" />
<Compile Include="Serialization\JsonDictionaryContract.cs" />
<Compile Include="Serialization\JsonDynamicContract.cs" />
<Compile Include="Serialization\JsonFormatterConverter.cs" />
<Compile Include="Serialization\JsonISerializableContract.cs" />
<Compile Include="Serialization\JsonLinqContract.cs" />
<Compile Include="Serialization\JsonObjectContract.cs" />
<Compile Include="Serialization\JsonPrimitiveContract.cs" />
<Compile Include="Serialization\JsonProperty.cs" />
<Compile Include="Serialization\JsonPropertyCollection.cs" />
<Compile Include="Serialization\JsonSerializerInternalBase.cs" />
<Compile Include="Serialization\JsonSerializerInternalReader.cs" />
<Compile Include="Serialization\JsonSerializerInternalWriter.cs" />
<Compile Include="Serialization\JsonSerializerProxy.cs" />
<Compile Include="Serialization\JsonStringContract.cs" />
<Compile Include="Serialization\JsonTypeReflector.cs" />
<Compile Include="Serialization\LateBoundMetadataTypeAttribute.cs" />
<Compile Include="Serialization\ObjectConstructor.cs" />
<Compile Include="Serialization\OnErrorAttribute.cs" />
<Compile Include="Serialization\ReflectionValueProvider.cs" />
<Compile Include="StreamingContext.cs" />
<Compile Include="TypeNameHandling.cs" />
<Compile Include="Utilities\Base64Encoder.cs" />
<Compile Include="Utilities\BidirectionalDictionary.cs" />
<Compile Include="Utilities\CollectionUtils.cs" />
<Compile Include="Utilities\CollectionWrapper.cs" />
<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" />
<Compile Include="Utilities\EnumValues.cs" />
<Compile Include="Utilities\ILGeneratorExtensions.cs" />
<Compile Include="Utilities\JavaScriptUtils.cs" />
<Compile Include="Utilities\LateBoundReflectionDelegateFactory.cs" />
<Compile Include="Utilities\LinqBridge.cs" />
<Compile Include="Utilities\ListWrapper.cs" />
<Compile Include="Utilities\MathUtils.cs" />
<Compile Include="Utilities\MethodCall.cs" />
<Compile Include="Utilities\MiscellaneousUtils.cs" />
<Compile Include="Utilities\ReflectionDelegateFactory.cs" />
<Compile Include="Utilities\ReflectionUtils.cs" />
<Compile Include="Utilities\StringBuffer.cs" />
<Compile Include="Utilities\StringReference.cs" />
<Compile Include="Utilities\StringUtils.cs" />
<Compile Include="Utilities\ThreadSafeStore.cs" />
<Compile Include="Utilities\TypeExtensions.cs" />
<Compile Include="Utilities\ValidationUtils.cs" />
<Compile Include="WriteState.cs" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
@@ -38,6 +38,8 @@ using System.Security;
[assembly: AssemblyTitle("Json.NET Silverlight")]
#elif PocketPC
[assembly: AssemblyTitle("Json.NET Compact")]
#elif PORTABLE
[assembly: AssemblyTitle("Json.NET Portable")]
#elif NETFX_CORE
[assembly: AssemblyTitle("Json.NET Metro")]
[assembly: AllowPartiallyTrustedCallers]
@@ -68,7 +70,7 @@ using System.Security;
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
#if !PORTABLE
// Setting ComVisible to false makes the types in this assembly not visible
// to COM componenets. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
@@ -76,6 +78,7 @@ using System.Security;
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("9ca358aa-317b-4925-8ada-4a29e943a363")]
#endif
// Version information for an assembly consists of the following four values:
//
@@ -88,7 +91,7 @@ using System.Security;
// by using the '*' as shown below:
[assembly: AssemblyVersion("4.5.0.0")]
#if !PocketPC
[assembly: AssemblyFileVersion("4.5.3.14817")]
[assembly: AssemblyFileVersion("4.5.3.14818")]
#endif
[assembly: CLSCompliant(true)]
@@ -31,7 +31,7 @@ namespace Newtonsoft.Json.Schema
/// <summary>
/// Returns detailed information about the schema exception.
/// </summary>
#if !(SILVERLIGHT || WINDOWS_PHONE || NETFX_CORE)
#if !(SILVERLIGHT || WINDOWS_PHONE || NETFX_CORE || PORTABLE)
[Serializable]
#endif
public class JsonSchemaException : Exception
@@ -83,7 +83,7 @@ namespace Newtonsoft.Json.Schema
{
}
#if !(WINDOWS_PHONE || SILVERLIGHT || NETFX_CORE)
#if !(WINDOWS_PHONE || SILVERLIGHT || NETFX_CORE || PORTABLE)
/// <summary>
/// Initializes a new instance of the <see cref="JsonSchemaException"/> class.
/// </summary>
@@ -182,7 +182,7 @@ namespace Newtonsoft.Json.Schema
if (containerAttribute != null && !string.IsNullOrEmpty(containerAttribute.Description))
return containerAttribute.Description;
#if !PocketPC && !NETFX_CORE
#if !(NETFX_CORE || PORTABLE)
DescriptionAttribute descriptionAttribute = ReflectionUtils.GetAttribute<DescriptionAttribute>(type);
if (descriptionAttribute != null)
return descriptionAttribute.Description;
@@ -330,14 +330,14 @@ namespace Newtonsoft.Json.Schema
}
}
break;
#if !SILVERLIGHT && !PocketPC && !NETFX_CORE
#if !(SILVERLIGHT || NETFX_CORE || PORTABLE)
case JsonContractType.Serializable:
CurrentSchema.Type = AddNullType(JsonSchemaType.Object, valueRequired);
CurrentSchema.Id = GetTypeId(type, false);
GenerateISerializableContract(type, (JsonISerializableContract) contract);
break;
#endif
#if !(NET35 || NET20 || WINDOWS_PHONE)
#if !(NET35 || NET20 || WINDOWS_PHONE || PORTABLE)
case JsonContractType.Dynamic:
#endif
case JsonContractType.Linq:
@@ -389,7 +389,7 @@ namespace Newtonsoft.Json.Schema
CurrentSchema.AllowAdditionalProperties = false;
}
#if !SILVERLIGHT && !PocketPC && !NETFX_CORE
#if !(SILVERLIGHT || NETFX_CORE || PORTABLE)
private void GenerateISerializableContract(Type type, JsonISerializableContract contract)
{
CurrentSchema.AllowAdditionalProperties = true;
@@ -430,7 +430,7 @@ namespace Newtonsoft.Json.Schema
case TypeCode.Empty:
case TypeCode.Object:
return schemaType | JsonSchemaType.String;
#if !NETFX_CORE
#if !(NETFX_CORE || PORTABLE)
case TypeCode.DBNull:
return schemaType | JsonSchemaType.Null;
#endif
@@ -26,7 +26,7 @@
using System;
using System.Reflection;
using Newtonsoft.Json.Utilities;
#if NETFX_CORE
#if NETFX_CORE || PORTABLE
using ICustomAttributeProvider = Newtonsoft.Json.Utilities.CustomAttributeProvider;
#endif
@@ -25,18 +25,18 @@
using System;
using System.Collections;
#if !(NET35 || NET20 || SILVERLIGHT || WINDOWS_PHONE)
#if !(NET35 || NET20 || SILVERLIGHT || WINDOWS_PHONE || PORTABLE)
using System.Collections.Concurrent;
#endif
using System.Collections.Generic;
using System.ComponentModel;
#if !(NET35 || NET20 || WINDOWS_PHONE)
#if !(NET35 || NET20 || WINDOWS_PHONE || PORTABLE)
using System.Dynamic;
#endif
using System.Globalization;
using System.Reflection;
using System.Runtime.Serialization;
#if !NETFX_CORE
#if !(NETFX_CORE || PORTABLE)
using System.Security.Permissions;
#endif
using System.Xml.Serialization;
@@ -44,7 +44,7 @@ using Newtonsoft.Json.Converters;
using Newtonsoft.Json.Utilities;
using Newtonsoft.Json.Linq;
using System.Runtime.CompilerServices;
#if NETFX_CORE
#if NETFX_CORE || PORTABLE
using ICustomAttributeProvider = Newtonsoft.Json.Utilities.CustomAttributeProvider;
#endif
#if NET20
@@ -97,21 +97,21 @@ namespace Newtonsoft.Json.Serialization
}
private static readonly IList<JsonConverter> BuiltInConverters = new List<JsonConverter>
{
#if !PocketPC && !SILVERLIGHT && !NET20 && !NETFX_CORE
#if !(SILVERLIGHT || NET20 || NETFX_CORE || PORTABLE)
new EntityKeyMemberConverter(),
#endif
#if !(NET35 || NET20 || WINDOWS_PHONE)
#if !(NET35 || NET20 || WINDOWS_PHONE || PORTABLE)
new ExpandoObjectConverter(),
#endif
new BinaryConverter(),
new KeyValuePairConverter(),
#if (!SILVERLIGHT || WINDOWS_PHONE)
#if (!(SILVERLIGHT || PORTABLE) || WINDOWS_PHONE)
new XmlNodeConverter(),
#endif
#if !SILVERLIGHT && !NETFX_CORE
#if !(SILVERLIGHT || NETFX_CORE || PORTABLE)
new BinaryConverter(),
new DataSetConverter(),
new DataTableConverter(),
#endif
new KeyValuePairConverter(),
new BsonObjectIdConverter()
};
@@ -151,7 +151,7 @@ namespace Newtonsoft.Json.Serialization
/// </value>
public bool SerializeCompilerGeneratedMembers { get; set; }
#if !(SILVERLIGHT || NETFX_CORE)
#if !(SILVERLIGHT || NETFX_CORE || PORTABLE)
/// <summary>
/// Gets or sets a value indicating whether to ignore the <see cref="ISerializable"/> interface when serializing and deserializing types.
/// </summary>
@@ -191,7 +191,7 @@ namespace Newtonsoft.Json.Serialization
#if !NETFX_CORE
DefaultMembersSearchFlags = BindingFlags.Public | BindingFlags.Instance;
#endif
#if !(SILVERLIGHT || NETFX_CORE)
#if !(SILVERLIGHT || NETFX_CORE || PORTABLE)
IgnoreSerializableAttribute = true;
#endif
@@ -256,7 +256,7 @@ namespace Newtonsoft.Json.Serialization
protected virtual List<MemberInfo> GetSerializableMembers(Type objectType)
{
bool ignoreSerializableAttribute;
#if !(SILVERLIGHT || NETFX_CORE)
#if !(SILVERLIGHT || NETFX_CORE || PORTABLE)
ignoreSerializableAttribute = IgnoreSerializableAttribute;
#else
ignoreSerializableAttribute = true;
@@ -349,7 +349,7 @@ namespace Newtonsoft.Json.Serialization
InitializeContract(contract);
bool ignoreSerializableAttribute;
#if !(SILVERLIGHT || NETFX_CORE)
#if !(SILVERLIGHT || NETFX_CORE || PORTABLE)
ignoreSerializableAttribute = IgnoreSerializableAttribute;
#else
ignoreSerializableAttribute = true;
@@ -553,7 +553,7 @@ namespace Newtonsoft.Json.Serialization
if (onDeserialized != null)
{
// ConcurrentDictionary throws an error here so don't use its OnDeserialized - http://json.codeplex.com/discussions/257093
#if !(NET35 || NET20 || SILVERLIGHT || WINDOWS_PHONE)
#if !(NET35 || NET20 || SILVERLIGHT || WINDOWS_PHONE || PORTABLE)
if (!t.IsGenericType() || (t.GetGenericTypeDefinition() != typeof(ConcurrentDictionary<,>)))
contract.OnDeserialized = onDeserialized;
#else
@@ -660,7 +660,7 @@ namespace Newtonsoft.Json.Serialization
return contract;
}
#if !SILVERLIGHT && !PocketPC && !NETFX_CORE
#if !(SILVERLIGHT || NETFX_CORE || PORTABLE)
/// <summary>
/// Creates a <see cref="JsonISerializableContract"/> for the given type.
/// </summary>
@@ -683,7 +683,7 @@ namespace Newtonsoft.Json.Serialization
}
#endif
#if !(NET35 || NET20 || WINDOWS_PHONE)
#if !(NET35 || NET20 || WINDOWS_PHONE || PORTABLE)
/// <summary>
/// Creates a <see cref="JsonDynamicContract"/> for the given type.
/// </summary>
@@ -744,12 +744,12 @@ namespace Newtonsoft.Json.Serialization
if (CanConvertToString(t))
return CreateStringContract(objectType);
#if !SILVERLIGHT && !PocketPC && !NETFX_CORE
#if !(SILVERLIGHT || NETFX_CORE || PORTABLE)
if (!IgnoreSerializableInterface && typeof(ISerializable).IsAssignableFrom(t))
return CreateISerializableContract(objectType);
#endif
#if !(NET35 || NET20 || WINDOWS_PHONE)
#if !(NET35 || NET20 || WINDOWS_PHONE || PORTABLE)
if (typeof(IDynamicMetaObjectProvider).IsAssignableFrom(t))
return CreateDynamicContract(objectType);
#endif
@@ -759,7 +759,7 @@ namespace Newtonsoft.Json.Serialization
internal static bool CanConvertToString(Type type)
{
#if !PocketPC && !NETFX_CORE
#if !(NETFX_CORE || PORTABLE)
TypeConverter converter = ConvertUtils.GetConverter(type);
// use the objectType's TypeConverter if it has one and can convert to a string
@@ -863,7 +863,7 @@ namespace Newtonsoft.Json.Serialization
// warning - this method use to cause errors with Intellitrace. Retest in VS Ultimate after changes
IValueProvider valueProvider;
#if !PocketPC && !SILVERLIGHT
#if !(SILVERLIGHT || PORTABLE)
if (DynamicCodeGeneration)
valueProvider = new DynamicValueProvider(member);
else
@@ -909,7 +909,7 @@ namespace Newtonsoft.Json.Serialization
DataContractAttribute dataContractAttribute = JsonTypeReflector.GetDataContractAttribute(declaringType);
MemberInfo memberInfo = null;
#if !NETFX_CORE
#if !(NETFX_CORE || PORTABLE)
memberInfo = attributeProvider as MemberInfo;
#else
memberInfo = attributeProvider.UnderlyingObject as MemberInfo;
@@ -957,7 +957,7 @@ namespace Newtonsoft.Json.Serialization
}
bool hasJsonIgnoreAttribute = JsonTypeReflector.GetAttribute<JsonIgnoreAttribute>(attributeProvider) != null
#if !(SILVERLIGHT || NETFX_CORE)
#if !(SILVERLIGHT || NETFX_CORE || PORTABLE)
|| JsonTypeReflector.GetAttribute<NonSerializedAttribute>(attributeProvider) != null
#endif
;
@@ -49,7 +49,7 @@ namespace Newtonsoft.Json.Serialization
{
Assembly assembly;
#if !SILVERLIGHT && !PocketPC && !NETFX_CORE
#if !(SILVERLIGHT || NETFX_CORE || PORTABLE)
// look, I don't like using obsolete methods as much as you do but this is the only way
// Assembly.Load won't check the GAC for a partial name
#pragma warning disable 618,612
@@ -23,7 +23,7 @@
// OTHER DEALINGS IN THE SOFTWARE.
#endregion
#if !PocketPC && !SILVERLIGHT
#if !(SILVERLIGHT || PORTABLE)
using System;
using System.Collections.Generic;
#if NET20
@@ -41,10 +41,10 @@ namespace Newtonsoft.Json.Serialization
Primitive,
String,
Dictionary,
#if !(NET35 || NET20 || WINDOWS_PHONE)
#if !(NET35 || NET20 || WINDOWS_PHONE || PORTABLE)
Dynamic,
#endif
#if !SILVERLIGHT && !PocketPC && !NETFX_CORE
#if !(SILVERLIGHT || NETFX_CORE || PORTABLE)
Serializable,
#endif
Linq
@@ -105,7 +105,7 @@ namespace Newtonsoft.Json.Serialization
internal IWrappedDictionary CreateWrapper(object dictionary)
{
#if !NETFX_CORE
#if !(NETFX_CORE)
if (dictionary is IDictionary && (DictionaryValueType == null || !_isDictionaryValueTypeNullableType))
return new DictionaryWrapper<object, object>((IDictionary)dictionary);
#endif
@@ -23,7 +23,7 @@
// OTHER DEALINGS IN THE SOFTWARE.
#endregion
#if !(NET35 || NET20 || WINDOWS_PHONE)
#if !(NET35 || NET20 || WINDOWS_PHONE || PORTABLE)
using System;
using System.Collections.Generic;
using System.Reflection;
@@ -23,7 +23,7 @@
// OTHER DEALINGS IN THE SOFTWARE.
#endregion
#if !(SILVERLIGHT || NETFX_CORE)
#if !(SILVERLIGHT || NETFX_CORE || PORTABLE)
using System;
using System.Globalization;
using System.Runtime.Serialization;
@@ -23,7 +23,7 @@
// OTHER DEALINGS IN THE SOFTWARE.
#endregion
#if !SILVERLIGHT && !PocketPC && !NETFX_CORE
#if !(SILVERLIGHT || NETFX_CORE || PORTABLE)
using System;
namespace Newtonsoft.Json.Serialization
@@ -42,7 +42,7 @@ namespace Newtonsoft.Json.Serialization
int IEqualityComparer<object>.GetHashCode(object obj)
{
#if !PocketPC && !NETFX_CORE
#if !(NETFX_CORE || PORTABLE)
// put objects in a bucket based on their reference
return RuntimeHelpers.GetHashCode(obj);
#else
@@ -27,7 +27,7 @@ using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
#if !(NET35 || NET20 || WINDOWS_PHONE)
#if !(NET35 || NET20 || WINDOWS_PHONE || PORTABLE)
using System.Dynamic;
#endif
using System.Globalization;
@@ -46,7 +46,7 @@ namespace Newtonsoft.Json.Serialization
internal class JsonSerializerInternalReader : JsonSerializerInternalBase
{
private JsonSerializerProxy _internalSerializer;
#if !SILVERLIGHT && !PocketPC && !NETFX_CORE
#if !(SILVERLIGHT || NETFX_CORE || PORTABLE)
private JsonFormatterConverter _formatterConverter;
#endif
@@ -134,7 +134,7 @@ namespace Newtonsoft.Json.Serialization
return _internalSerializer;
}
#if !SILVERLIGHT && !PocketPC && !NETFX_CORE
#if !(SILVERLIGHT || NETFX_CORE || PORTABLE)
private JsonFormatterConverter GetFormatterConverter()
{
if (_formatterConverter == null)
@@ -268,7 +268,7 @@ namespace Newtonsoft.Json.Serialization
return constructorName;
case JsonToken.Null:
case JsonToken.Undefined:
#if !NETFX_CORE
#if !(NETFX_CORE || PORTABLE)
if (objectType == typeof (DBNull))
return DBNull.Value;
#endif
@@ -462,12 +462,12 @@ namespace Newtonsoft.Json.Serialization
return CreateAndPopulateDictionary(reader, dictionaryContract, id);
return PopulateDictionary(dictionaryContract.CreateWrapper(existingValue), reader, dictionaryContract, id);
#if !(NET35 || NET20 || WINDOWS_PHONE)
#if !(NET35 || NET20 || WINDOWS_PHONE || PORTABLE)
case JsonContractType.Dynamic:
JsonDynamicContract dynamicContract = (JsonDynamicContract) contract;
return CreateDynamic(reader, dynamicContract, id);
#endif
#if !SILVERLIGHT && !PocketPC && !NETFX_CORE
#if !(SILVERLIGHT || NETFX_CORE || PORTABLE)
case JsonContractType.Serializable:
JsonISerializableContract serializableContract = (JsonISerializableContract) contract;
return CreateISerializable(reader, serializableContract, id);
@@ -521,7 +521,7 @@ To force JSON arrays to deserialize add the JsonArrayAttribute to the type.".For
private bool HasDefinedType(Type type)
{
return (type != null && type != typeof (object) && !typeof (JToken).IsSubclassOf(type)
#if !(NET35 || NET20 || WINDOWS_PHONE)
#if !(NET35 || NET20 || WINDOWS_PHONE || PORTABLE)
&& type != typeof (IDynamicMetaObjectProvider)
#endif
);
@@ -824,7 +824,7 @@ To force JSON arrays to deserialize add the JsonArrayAttribute to the type.".For
throw CreateSerializationException(reader, "Unexpected end when deserializing array.");
}
#if !SILVERLIGHT && !PocketPC && !NETFX_CORE
#if !(SILVERLIGHT || NETFX_CORE || PORTABLE)
private object CreateISerializable(JsonReader reader, JsonISerializableContract contract, string id)
{
Type objectType = contract.UnderlyingType;
@@ -875,7 +875,7 @@ To fix this error either change the environment to be fully trusted, change the
}
#endif
#if !(NET35 || NET20 || WINDOWS_PHONE)
#if !(NET35 || NET20 || WINDOWS_PHONE || PORTABLE)
private object CreateDynamic(JsonReader reader, JsonDynamicContract contract, string id)
{
IDynamicMetaObjectProvider newObject = null;
@@ -27,7 +27,7 @@ using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
#if !(NET35 || NET20 || WINDOWS_PHONE)
#if !(NET35 || NET20 || WINDOWS_PHONE || PORTABLE)
using System.Dynamic;
#endif
using System.Globalization;
@@ -135,12 +135,12 @@ namespace Newtonsoft.Json.Serialization
JsonDictionaryContract dictionaryContract = (JsonDictionaryContract) valueContract;
SerializeDictionary(writer, dictionaryContract.CreateWrapper(value), dictionaryContract, member, collectionValueContract);
break;
#if !(NET35 || NET20 || WINDOWS_PHONE)
#if !(NET35 || NET20 || WINDOWS_PHONE || PORTABLE)
case JsonContractType.Dynamic:
SerializeDynamic(writer, (IDynamicMetaObjectProvider) value, (JsonDynamicContract) valueContract, member, collectionValueContract);
break;
#endif
#if !SILVERLIGHT && !PocketPC && !NETFX_CORE
#if !(SILVERLIGHT || NETFX_CORE || PORTABLE)
case JsonContractType.Serializable:
SerializeISerializable(writer, (ISerializable) value, (JsonISerializableContract) valueContract, member, collectionValueContract);
break;
@@ -248,7 +248,7 @@ namespace Newtonsoft.Json.Serialization
internal static bool TryConvertToString(object value, Type type, out string s)
{
#if !(PocketPC || NETFX_CORE)
#if !(PocketPC || NETFX_CORE || PORTABLE)
TypeConverter converter = ConvertUtils.GetConverter(type);
// use the objectType's TypeConverter if it has one and can convert to a string
@@ -484,7 +484,7 @@ namespace Newtonsoft.Json.Serialization
return writeMetadataObject;
}
#if !SILVERLIGHT && !PocketPC && !NETFX_CORE
#if !(SILVERLIGHT || NETFX_CORE || PORTABLE)
#if !NET20
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Portability", "CA1903:UseOnlyApiFromTargetedFramework", MessageId = "System.Security.SecuritySafeCriticalAttribute")]
[SecuritySafeCritical]
@@ -518,7 +518,7 @@ To fix this error either change the environment to be fully trusted, change the
}
#endif
#if !(NET35 || NET20 || WINDOWS_PHONE)
#if !(NET35 || NET20 || WINDOWS_PHONE || PORTABLE)
private void SerializeDynamic(JsonWriter writer, IDynamicMetaObjectProvider value, JsonDynamicContract contract, JsonProperty member, JsonContract collectionValueContract)
{
contract.InvokeOnSerializing(value, Serializer.Context);
@@ -27,11 +27,11 @@ using System;
using System.ComponentModel;
using System.Globalization;
using System.Reflection;
#if !NETFX_CORE
#if !(NETFX_CORE || PORTABLE)
using System.Security.Permissions;
#endif
using Newtonsoft.Json.Utilities;
#if NETFX_CORE
#if NETFX_CORE || PORTABLE
using ICustomAttributeProvider = Newtonsoft.Json.Utilities.CustomAttributeProvider;
#endif
#if NET20
@@ -62,7 +62,7 @@ namespace Newtonsoft.Json.Serialization
public const string SpecifiedPostfix = "Specified";
private static readonly ThreadSafeStore<ICustomAttributeProvider, Type> JsonConverterTypeCache = new ThreadSafeStore<ICustomAttributeProvider, Type>(GetJsonConverterTypeFromAttribute);
#if !SILVERLIGHT && !PocketPC && !NET20 && !NETFX_CORE
#if !(SILVERLIGHT || NET20 || NETFX_CORE || PORTABLE)
private static readonly ThreadSafeStore<Type, Type> AssociatedMetadataTypesCache = new ThreadSafeStore<Type, Type>(GetAssociateMetadataTypeFromAttribute);
private const string MetadataTypeAttributeTypeName =
@@ -102,7 +102,7 @@ namespace Newtonsoft.Json.Serialization
return GetJsonContainerAttribute(type) as JsonArrayAttribute;
}
#if !(SILVERLIGHT || NETFX_CORE)
#if !(SILVERLIGHT || NETFX_CORE || PORTABLE)
public static SerializableAttribute GetSerializableAttribute(Type type)
{
return CachedAttributeGetter<SerializableAttribute>.GetAttribute(type.GetCustomAttributeProvider());
@@ -171,7 +171,7 @@ namespace Newtonsoft.Json.Serialization
return MemberSerialization.OptIn;
#endif
#if !(SILVERLIGHT || NETFX_CORE)
#if !(SILVERLIGHT || NETFX_CORE || PORTABLE)
if (!ignoreSerializableAttribute)
{
SerializableAttribute serializableAttribute = GetSerializableAttribute(objectType);
@@ -200,7 +200,7 @@ namespace Newtonsoft.Json.Serialization
public static JsonConverter GetJsonConverter(ICustomAttributeProvider attributeProvider, Type targetConvertedType)
{
object provider = null;
#if !NETFX_CORE
#if !(NETFX_CORE || PORTABLE)
provider = attributeProvider as MemberInfo;
#else
provider = attributeProvider.UnderlyingObject;
@@ -221,7 +221,7 @@ namespace Newtonsoft.Json.Serialization
return null;
}
#if !NETFX_CORE
#if !(NETFX_CORE || PORTABLE)
#if !PocketPC
public static TypeConverter GetTypeConverter(Type type)
{
@@ -239,7 +239,7 @@ namespace Newtonsoft.Json.Serialization
}
#endif
#if !SILVERLIGHT && !PocketPC && !NET20 && !NETFX_CORE
#if !(SILVERLIGHT || NET20 || NETFX_CORE || PORTABLE)
private static Type GetAssociatedMetadataType(Type type)
{
return AssociatedMetadataTypesCache.Get(type);
@@ -284,7 +284,7 @@ namespace Newtonsoft.Json.Serialization
{
T attribute;
#if !SILVERLIGHT && !PocketPC && !NET20 && !NETFX_CORE
#if !(SILVERLIGHT || NET20 || NETFX_CORE || PORTABLE)
Type metadataType = GetAssociatedMetadataType(type);
if (metadataType != null)
{
@@ -312,7 +312,7 @@ namespace Newtonsoft.Json.Serialization
{
T attribute;
#if !SILVERLIGHT && !PocketPC && !NET20 && !NETFX_CORE
#if !(SILVERLIGHT || NET20 || NETFX_CORE || PORTABLE)
Type metadataType = GetAssociatedMetadataType(memberInfo.DeclaringType);
if (metadataType != null)
{
@@ -352,7 +352,7 @@ namespace Newtonsoft.Json.Serialization
public static T GetAttribute<T>(ICustomAttributeProvider attributeProvider) where T : Attribute
{
object provider = null;
#if !NETFX_CORE
#if !(NETFX_CORE || PORTABLE)
provider = attributeProvider;
#else
provider = attributeProvider.UnderlyingObject;
@@ -390,7 +390,7 @@ namespace Newtonsoft.Json.Serialization
{
if (_dynamicCodeGeneration == null)
{
#if !PocketPC && !SILVERLIGHT && !NETFX_CORE
#if !(SILVERLIGHT || NETFX_CORE || PORTABLE)
try
{
new ReflectionPermission(ReflectionPermissionFlag.MemberAccess).Demand();
@@ -419,7 +419,7 @@ namespace Newtonsoft.Json.Serialization
{
if (_fullyTrusted == null)
{
#if (NETFX_CORE || SILVERLIGHT)
#if (NETFX_CORE || SILVERLIGHT || PORTABLE)
_fullyTrusted = false;
#elif !(NET20 || NET35)
AppDomain appDomain = AppDomain.CurrentDomain;
@@ -446,7 +446,7 @@ namespace Newtonsoft.Json.Serialization
{
get
{
#if !PocketPC && !SILVERLIGHT
#if !(SILVERLIGHT || PORTABLE)
if (DynamicCodeGeneration)
return DynamicReflectionDelegateFactory.Instance;
#endif
+1 -1
View File
@@ -1,4 +1,4 @@
#if SILVERLIGHT || PocketPC || NETFX_CORE
#if SILVERLIGHT || PocketPC || NETFX_CORE || PORTABLE
using System;
using System.Reflection;
@@ -32,7 +32,7 @@ using System.Reflection;
using Newtonsoft.Json.Utilities.LinqBridge;
#endif
#if !(SILVERLIGHT || NETFX_CORE)
#if !(SILVERLIGHT || NETFX_CORE || PORTABLE)
using System.Data.SqlTypes;
#endif
#if NETFX_CORE
@@ -134,7 +134,7 @@ namespace Newtonsoft.Json.Utilities
public static TypeCode GetTypeCode(object o)
{
#if !NETFX_CORE
#if !(NETFX_CORE || PORTABLE)
return System.Convert.GetTypeCode(o);
#else
return GetTypeCode(o.GetType());
@@ -330,14 +330,14 @@ namespace Newtonsoft.Json.Utilities
if (targetType == typeof (Uri))
return new Uri((string) initialValue);
if (targetType == typeof (TimeSpan))
#if !(NET35 || NET20 || SILVERLIGHT)
#if !(NET35 || NET20 || SILVERLIGHT || PORTABLE)
return TimeSpan.Parse((string) initialValue, CultureInfo.InvariantCulture);
#else
return TimeSpan.Parse((string)initialValue);
#endif
}
#if !PocketPC && !NETFX_CORE
#if !(NETFX_CORE || PORTABLE)
// see if source or target types have a TypeConverter that converts between the two
TypeConverter toConverter = GetConverter(initialType);
@@ -361,7 +361,7 @@ namespace Newtonsoft.Json.Utilities
#endif
}
#endif
#if !NETFX_CORE
#if !(NETFX_CORE || PORTABLE)
// handle DBNull and INullable
if (initialValue == DBNull.Value)
{
@@ -371,7 +371,7 @@ namespace Newtonsoft.Json.Utilities
throw new Exception("Can not convert null {0} into non-nullable {1}.".FormatWith(CultureInfo.InvariantCulture, initialType, targetType));
}
#endif
#if !SILVERLIGHT && !NETFX_CORE
#if !(SILVERLIGHT || NETFX_CORE || PORTABLE)
if (initialValue is INullable)
return EnsureTypeAssignable(ToValue((INullable)initialValue), initialType, targetType);
#endif
@@ -448,7 +448,7 @@ namespace Newtonsoft.Json.Utilities
throw new Exception("Could not cast or convert from {0} to {1}.".FormatWith(CultureInfo.InvariantCulture, (initialType != null) ? initialType.ToString() : "{null}", targetType));
}
#if !SILVERLIGHT && !NETFX_CORE
#if !(SILVERLIGHT || NETFX_CORE || PORTABLE)
public static object ToValue(INullable nullableValue)
{
if (nullableValue == null)
@@ -468,7 +468,7 @@ namespace Newtonsoft.Json.Utilities
}
#endif
#if !PocketPC && !NETFX_CORE
#if !(NETFX_CORE || PORTABLE)
internal static TypeConverter GetConverter(Type t)
{
return JsonTypeReflector.GetTypeConverter(t);
@@ -15,14 +15,14 @@ namespace Newtonsoft.Json.Utilities
public static TimeSpan GetUtcOffset(this DateTime d)
{
#if PocketPC || NET20
#if NET20
return TimeZone.CurrentTimeZone.GetUtcOffset(d);
#else
return TimeZoneInfo.Local.GetUtcOffset(d);
#endif
}
#if !NETFX_CORE
#if !(NETFX_CORE || PORTABLE)
public static XmlDateTimeSerializationMode ToSerializationMode(DateTimeKind kind)
{
switch (kind)
@@ -10,7 +10,7 @@ using System.Linq;
namespace Newtonsoft.Json.Utilities
{
#if NETFX_CORE
#if (NETFX_CORE)
internal interface IDictionary : ICollection
{
object this[object key] { get; set; }
@@ -85,7 +85,7 @@ namespace Newtonsoft.Json.Utilities
_dictionary.Add(key, value);
else
#endif
_genericDictionary.Add(key, value);
_genericDictionary.Add(key, value);
}
public bool ContainsKey(TKey key)
@@ -95,7 +95,7 @@ namespace Newtonsoft.Json.Utilities
return _dictionary.Contains(key);
else
#endif
return _genericDictionary.ContainsKey(key);
return _genericDictionary.ContainsKey(key);
}
public ICollection<TKey> Keys
@@ -107,7 +107,7 @@ namespace Newtonsoft.Json.Utilities
return _dictionary.Keys.Cast<TKey>().ToList();
else
#endif
return _genericDictionary.Keys;
return _genericDictionary.Keys;
}
}
@@ -182,7 +182,7 @@ namespace Newtonsoft.Json.Utilities
_dictionary[key] = value;
else
#endif
_genericDictionary[key] = value;
_genericDictionary[key] = value;
}
}
@@ -193,7 +193,7 @@ namespace Newtonsoft.Json.Utilities
((IList)_dictionary).Add(item);
else
#endif
_genericDictionary.Add(item);
_genericDictionary.Add(item);
}
public void Clear()
@@ -203,7 +203,7 @@ namespace Newtonsoft.Json.Utilities
_dictionary.Clear();
else
#endif
_genericDictionary.Clear();
_genericDictionary.Clear();
}
public bool Contains(KeyValuePair<TKey, TValue> item)
@@ -213,7 +213,7 @@ namespace Newtonsoft.Json.Utilities
return ((IList)_dictionary).Contains(item);
else
#endif
return _genericDictionary.Contains(item);
return _genericDictionary.Contains(item);
}
public void CopyTo(KeyValuePair<TKey, TValue>[] array, int arrayIndex)
@@ -242,7 +242,7 @@ namespace Newtonsoft.Json.Utilities
return _dictionary.Count;
else
#endif
return _genericDictionary.Count;
return _genericDictionary.Count;
}
}
@@ -255,7 +255,7 @@ namespace Newtonsoft.Json.Utilities
return _dictionary.IsReadOnly;
else
#endif
return _genericDictionary.IsReadOnly;
return _genericDictionary.IsReadOnly;
}
}
@@ -297,7 +297,7 @@ namespace Newtonsoft.Json.Utilities
return _dictionary.Cast<DictionaryEntry>().Select(de => new KeyValuePair<TKey, TValue>((TKey)de.Key, (TValue)de.Value)).GetEnumerator();
else
#endif
return _genericDictionary.GetEnumerator();
return _genericDictionary.GetEnumerator();
}
IEnumerator IEnumerable.GetEnumerator()
@@ -312,7 +312,7 @@ namespace Newtonsoft.Json.Utilities
_dictionary.Add(key, value);
else
#endif
_genericDictionary.Add((TKey)key, (TValue)value);
_genericDictionary.Add((TKey)key, (TValue)value);
}
object IDictionary.this[object key]
@@ -324,7 +324,7 @@ namespace Newtonsoft.Json.Utilities
return _dictionary[key];
else
#endif
return _genericDictionary[(TKey)key];
return _genericDictionary[(TKey)key];
}
set
{
@@ -333,7 +333,7 @@ namespace Newtonsoft.Json.Utilities
_dictionary[key] = value;
else
#endif
_genericDictionary[(TKey)key] = (TValue)value;
_genericDictionary[(TKey)key] = (TValue)value;
}
}
@@ -385,7 +385,7 @@ namespace Newtonsoft.Json.Utilities
return _dictionary.GetEnumerator();
else
#endif
return new DictionaryEnumerator<TKey, TValue>(_genericDictionary.GetEnumerator());
return new DictionaryEnumerator<TKey, TValue>(_genericDictionary.GetEnumerator());
}
#if !NETFX_CORE
@@ -427,7 +427,7 @@ namespace Newtonsoft.Json.Utilities
_dictionary.Remove(key);
else
#endif
_genericDictionary.Remove((TKey)key);
_genericDictionary.Remove((TKey)key);
}
#if !NETFX_CORE
@@ -450,7 +450,7 @@ namespace Newtonsoft.Json.Utilities
_dictionary.CopyTo(array, index);
else
#endif
_genericDictionary.CopyTo((KeyValuePair<TKey, TValue>[])array, index);
_genericDictionary.CopyTo((KeyValuePair<TKey, TValue>[])array, index);
}
bool ICollection.IsSynchronized
@@ -462,7 +462,7 @@ namespace Newtonsoft.Json.Utilities
return _dictionary.IsSynchronized;
else
#endif
return false;
return false;
}
}
@@ -486,7 +486,7 @@ namespace Newtonsoft.Json.Utilities
return _dictionary;
else
#endif
return _genericDictionary;
return _genericDictionary;
}
}
}
@@ -1,4 +1,4 @@
#if !(NET35 || NET20 || WINDOWS_PHONE)
#if !(NET35 || NET20 || WINDOWS_PHONE || PORTABLE)
using System;
using System.Collections.Generic;
using System.Dynamic;
@@ -1,4 +1,4 @@
#if !(NET35 || NET20 || WINDOWS_PHONE)
#if !(NET35 || NET20 || WINDOWS_PHONE || PORTABLE)
using System;
using System.Collections.Generic;
using System.Dynamic;
@@ -23,7 +23,7 @@
// OTHER DEALINGS IN THE SOFTWARE.
#endregion
#if !PocketPC && !SILVERLIGHT
#if !(SILVERLIGHT || PORTABLE)
using System;
using System.Collections.Generic;
#if NET20
@@ -1,4 +1,4 @@
#if !(NET35 || NET20 || WINDOWS_PHONE)
#if !(NET35 || NET20 || WINDOWS_PHONE || PORTABLE)
using System;
using System.Collections.Generic;
using System.Dynamic;
@@ -1,4 +1,4 @@
#if !SILVERLIGHT && !PocketPC && !NETFX_CORE
#if !(SILVERLIGHT || NETFX_CORE || PORTABLE)
using System;
using System.Collections.Generic;
using System.IO;
@@ -23,7 +23,7 @@
// OTHER DEALINGS IN THE SOFTWARE.
#endregion
#if !PocketPC && !SILVERLIGHT
#if !(SILVERLIGHT || PORTABLE)
using System;
using System.Reflection.Emit;
using System.Reflection;
@@ -31,7 +31,7 @@ using System.Globalization;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters;
using System.Text;
#if NETFX_CORE
#if NETFX_CORE || PORTABLE
using IConvertible = Newtonsoft.Json.Utilities.Convertible;
using ICustomAttributeProvider = Newtonsoft.Json.Utilities.CustomAttributeProvider;
#endif
@@ -44,6 +44,32 @@ using Newtonsoft.Json.Serialization;
namespace Newtonsoft.Json.Utilities
{
#if NETFX_CORE || PORTABLE
internal enum MemberTypes
{
Property,
Field,
Event,
Method,
Other
}
internal class CustomAttributeProvider
{
private readonly object _underlyingObject;
public CustomAttributeProvider(object o)
{
_underlyingObject = o;
}
public object UnderlyingObject
{
get { return _underlyingObject; }
}
}
#endif
#if NETFX_CORE
internal enum TypeCode
{
@@ -66,15 +92,6 @@ namespace Newtonsoft.Json.Utilities
Decimal
}
internal enum MemberTypes
{
Property,
Field,
Event,
Method,
Other
}
[Flags]
internal enum BindingFlags
{
@@ -99,21 +116,6 @@ namespace Newtonsoft.Json.Utilities
OptionalParamBinding = 262144,
IgnoreReturn = 16777216
}
internal class CustomAttributeProvider
{
private readonly object _underlyingObject;
public CustomAttributeProvider(object o)
{
_underlyingObject = o;
}
public object UnderlyingObject
{
get { return _underlyingObject; }
}
}
#endif
internal static class ReflectionUtils
@@ -122,7 +124,7 @@ namespace Newtonsoft.Json.Utilities
static ReflectionUtils()
{
#if !NETFX_CORE
#if !(NETFX_CORE || PORTABLE)
EmptyTypes = Type.EmptyTypes;
#else
EmptyTypes = new Type[0];
@@ -131,7 +133,7 @@ namespace Newtonsoft.Json.Utilities
public static ICustomAttributeProvider GetCustomAttributeProvider(this object o)
{
#if !NETFX_CORE
#if !(NETFX_CORE || PORTABLE)
return (ICustomAttributeProvider)o;
#else
return new ICustomAttributeProvider(o);
@@ -274,7 +276,7 @@ namespace Newtonsoft.Json.Utilities
if (nonPublic)
bindingFlags = bindingFlags | BindingFlags.NonPublic;
return t.GetConstructor(bindingFlags, null, ReflectionUtils.EmptyTypes, null);
return t.GetConstructors(bindingFlags).SingleOrDefault(c => !c.GetParameters().Any());
}
public static bool IsNullable(Type t)
@@ -705,30 +707,44 @@ namespace Newtonsoft.Json.Utilities
return attributes.SingleOrDefault();
}
#if !NETFX_CORE
#if !(NETFX_CORE)
public static T[] GetAttributes<T>(ICustomAttributeProvider attributeProvider, bool inherit) where T : Attribute
{
ValidationUtils.ArgumentNotNull(attributeProvider, "attributeProvider");
object provider;
#if !PORTABLE
provider = attributeProvider;
#else
provider = attributeProvider.UnderlyingObject;
#endif
// http://hyperthink.net/blog/getcustomattributes-gotcha/
// ICustomAttributeProvider doesn't do inheritance
if (attributeProvider is Type)
return (T[])((Type)attributeProvider).GetCustomAttributes(typeof(T), inherit);
if (provider is Type)
return (T[])((Type)provider).GetCustomAttributes(typeof(T), inherit);
if (attributeProvider is Assembly)
return (T[])Attribute.GetCustomAttributes((Assembly)attributeProvider, typeof(T), inherit);
if (provider is Assembly)
return (T[])Attribute.GetCustomAttributes((Assembly)provider, typeof(T));
if (attributeProvider is MemberInfo)
return (T[])Attribute.GetCustomAttributes((MemberInfo)attributeProvider, typeof(T), inherit);
if (provider is MemberInfo)
return (T[])Attribute.GetCustomAttributes((MemberInfo)provider, typeof(T), inherit);
if (attributeProvider is Module)
return (T[])Attribute.GetCustomAttributes((Module)attributeProvider, typeof(T), inherit);
#if !PORTABLE
if (provider is Module)
return (T[])Attribute.GetCustomAttributes((Module)provider, typeof(T), inherit);
#endif
if (attributeProvider is ParameterInfo)
return (T[])Attribute.GetCustomAttributes((ParameterInfo)attributeProvider, typeof(T), inherit);
if (provider is ParameterInfo)
return (T[])Attribute.GetCustomAttributes((ParameterInfo)provider, typeof(T), inherit);
#if !PORTABLE
return (T[])attributeProvider.GetCustomAttributes(typeof(T), inherit);
#else
throw new Exception("Cannot get attributes from '{0}'.".FormatWith(CultureInfo.InvariantCulture, provider));
#endif
}
#else
public static T[] GetAttributes<T>(ICustomAttributeProvider attributeProvider, bool inherit) where T : Attribute
@@ -981,8 +997,9 @@ namespace Newtonsoft.Json.Utilities
public static bool IsMethodOverridden(Type currentType, Type methodDeclaringType, string method)
{
bool isMethodOverriden = currentType.GetMember(method, MemberTypes.Method, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance).Cast<MethodInfo>()
bool isMethodOverriden = currentType.GetMethods(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance)
.Any(info =>
info.Name == method &&
// check that the method overrides the original on DynamicObjectProxy
info.DeclaringType != methodDeclaringType
// todo - find out whether there is a way to do this in winrt
+3 -3
View File
@@ -141,7 +141,7 @@ namespace Newtonsoft.Json.Utilities
return s;
string camelCase = null;
#if !NETFX_CORE
#if !(NETFX_CORE || PORTABLE)
camelCase = char.ToLower(s[0], CultureInfo.InvariantCulture).ToString(CultureInfo.InvariantCulture);
#else
camelCase = char.ToLower(s[0]).ToString();
@@ -155,7 +155,7 @@ namespace Newtonsoft.Json.Utilities
public static bool IsHighSurrogate(char c)
{
#if !SILVERLIGHT
#if !(SILVERLIGHT || PORTABLE)
return char.IsHighSurrogate(c);
#else
return (c >= 55296 && c <= 56319);
@@ -164,7 +164,7 @@ namespace Newtonsoft.Json.Utilities
public static bool IsLowSurrogate(char c)
{
#if !SILVERLIGHT
#if !(SILVERLIGHT || PORTABLE)
return char.IsLowSurrogate(c);
#else
return (c >= 56320 && c <= 57343);
+71 -34
View File
@@ -55,7 +55,7 @@ namespace Newtonsoft.Json.Utilities
public static MemberTypes MemberType(this MemberInfo memberInfo)
{
#if !NETFX_CORE
#if !(NETFX_CORE || PORTABLE)
return memberInfo.MemberType;
#else
if (memberInfo is PropertyInfo)
@@ -71,6 +71,7 @@ namespace Newtonsoft.Json.Utilities
#endif
}
#if !PORTABLE
public static Module Module(this Type type)
{
#if !NETFX_CORE
@@ -79,6 +80,7 @@ namespace Newtonsoft.Json.Utilities
return type.GetTypeInfo().Module;
#endif
}
#endif
public static bool ContainsGenericParameters(this Type type)
{
@@ -152,6 +154,41 @@ namespace Newtonsoft.Json.Utilities
#endif
}
#if PORTABLE
public static PropertyInfo GetProperty(this Type type, string name, BindingFlags bindingFlags, object placeholder1, Type propertyType, IList<Type> indexParameters, object placeholder2)
{
IList<PropertyInfo> propertyInfos = type.GetProperties(bindingFlags);
return propertyInfos.Where(p =>
{
if (name != null && name != p.Name)
return false;
if (propertyType != null && propertyType != p.PropertyType)
return false;
if (indexParameters != null)
{
if (!p.GetIndexParameters().Select(ip => ip.ParameterType).SequenceEqual(indexParameters))
return false;
}
return true;
}).SingleOrDefault();
}
public static IEnumerable<MemberInfo> GetMember(this Type type, string name, MemberTypes memberType, BindingFlags bindingFlags)
{
return type.GetMembers(bindingFlags).Where(m =>
{
if (name != null && name != m.Name)
return false;
if (m.MemberType() != memberType)
return false;
return true;
});
}
#endif
#if NETFX_CORE
public static bool IsDefined(this Type type, Type attributeType, bool inherit)
{
@@ -168,39 +205,6 @@ namespace Newtonsoft.Json.Utilities
return type.GetTypeInfo().GetDeclaredMethod(name);
}
public static PropertyInfo GetProperty(this Type type, string name, BindingFlags bindingFlags, object placeholder1, Type propertyType, IList<Type> indexParameters, object placeholder2)
{
return type.GetTypeInfo().DeclaredProperties.Where(p =>
{
if (name != null && name != p.Name)
return false;
if (propertyType != null && propertyType != p.PropertyType)
return false;
if (indexParameters != null)
{
if (!p.GetIndexParameters().Select(ip => ip.ParameterType).SequenceEqual(indexParameters))
return false;
}
return true;
}).SingleOrDefault();
}
public static IEnumerable<MemberInfo> GetMember(this Type type, string name, MemberTypes memberType, BindingFlags bindingFlags)
{
return type.GetTypeInfo().GetMembersRecursive().Where(m =>
{
if (name != null && name != m.Name)
return false;
if (m.MemberType() != memberType)
return false;
if (!TestAccessibility(m, bindingFlags))
return false;
return true;
});
}
public static MethodInfo GetMethod(this Type type, IList<Type> parameterTypes)
{
return type.GetMethod(null, parameterTypes);
@@ -225,6 +229,39 @@ namespace Newtonsoft.Json.Utilities
}).SingleOrDefault();
}
public static PropertyInfo GetProperty(this Type type, string name, BindingFlags bindingFlags, object placeholder1, Type propertyType, IList<Type> indexParameters, object placeholder2)
{
return type.GetTypeInfo().DeclaredProperties.Where(p =>
{
if (name != null && name != p.Name)
return false;
if (propertyType != null && propertyType != p.PropertyType)
return false;
if (indexParameters != null)
{
if (!p.GetIndexParameters().Select(ip => ip.ParameterType).SequenceEqual(indexParameters))
return false;
}
return true;
}).SingleOrDefault();
}
public static IEnumerable<MemberInfo> GetMember(this Type type, string name, MemberTypes memberType, BindingFlags bindingFlags)
{
return type.GetTypeInfo().GetMembersRecursive().Where(m =>
{
if (name != null && name != m.Name)
return false;
if (m.MemberType() != memberType)
return false;
if (!TestAccessibility(m, bindingFlags))
return false;
return true;
});
}
public static IEnumerable<ConstructorInfo> GetConstructors(this Type type)
{
return type.GetConstructors(DefaultFlags);