-Incremented version to 4.0.8
-Added VersionConverter -Fixed converting XML to JSON with a default namespace -Changed Silverlight/Windows Phone assemblies to not be signed
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
<metadata>
|
||||
<id>Newtonsoft.Json</id>
|
||||
<title>Json.NET</title>
|
||||
<version>4.0.7</version>
|
||||
<version>4.0.8</version>
|
||||
<authors>James Newton-King</authors>
|
||||
<description>Json.NET is a popular high-performance JSON framework for .NET</description>
|
||||
<language>en-US</language>
|
||||
|
||||
+10
-30
@@ -1,6 +1,6 @@
|
||||
properties {
|
||||
$zipFileName = "Json40r7.zip"
|
||||
$majorVersion = "4.0.7"
|
||||
$zipFileName = "Json40r8.zip"
|
||||
$majorVersion = "4.0.8"
|
||||
$version = GetVersion $majorVersion
|
||||
$signAssemblies = $false
|
||||
$signKeyPath = "D:\Development\Releases\newtonsoft.snk"
|
||||
@@ -15,11 +15,11 @@
|
||||
$releaseDir = "$baseDir\Release"
|
||||
$workingDir = "$baseDir\Working"
|
||||
$builds = @(
|
||||
@{Name = "Newtonsoft.Json"; TestsName = "Newtonsoft.Json.Tests"; Constants=""; FinalDir="Net"; NuGetDir = "net40"; Framework="net-4.0"},
|
||||
@{Name = "Newtonsoft.Json.WindowsPhone"; TestsName = $null; Constants="SILVERLIGHT;WINDOWS_PHONE"; FinalDir="WindowsPhone"; NuGetDir = "sl3-wp,sl4-windowsphone71"; Framework="net-4.0"},
|
||||
@{Name = "Newtonsoft.Json.Silverlight"; TestsName = "Newtonsoft.Json.Tests.Silverlight"; Constants="SILVERLIGHT"; FinalDir="Silverlight"; NuGetDir = "sl4"; Framework="net-4.0"},
|
||||
@{Name = "Newtonsoft.Json.Net35"; TestsName = "Newtonsoft.Json.Tests.Net35"; Constants="NET35"; FinalDir="Net35"; NuGetDir = "net35"; Framework="net-2.0"},
|
||||
@{Name = "Newtonsoft.Json.Net20"; TestsName = "Newtonsoft.Json.Tests.Net20"; Constants="NET20"; FinalDir="Net20"; NuGetDir = "net20"; Framework="net-2.0"}
|
||||
@{Name = "Newtonsoft.Json"; TestsName = "Newtonsoft.Json.Tests"; Constants=""; FinalDir="Net40"; NuGetDir = "net40"; Framework="net-4.0"; Sign=$true},
|
||||
@{Name = "Newtonsoft.Json.WindowsPhone"; TestsName = $null; Constants="SILVERLIGHT;WINDOWS_PHONE"; FinalDir="WindowsPhone"; NuGetDir = "sl3-wp,sl4-windowsphone71"; Framework="net-4.0"; Sign=$false},
|
||||
@{Name = "Newtonsoft.Json.Silverlight"; TestsName = "Newtonsoft.Json.Tests.Silverlight"; Constants="SILVERLIGHT"; FinalDir="Silverlight"; NuGetDir = "sl4"; Framework="net-4.0"; Sign=$false},
|
||||
@{Name = "Newtonsoft.Json.Net35"; TestsName = "Newtonsoft.Json.Tests.Net35"; Constants="NET35"; FinalDir="Net35"; NuGetDir = "net35"; Framework="net-2.0"; Sign=$true},
|
||||
@{Name = "Newtonsoft.Json.Net20"; TestsName = "Newtonsoft.Json.Tests.Net20"; Constants="NET20"; FinalDir="Net20"; NuGetDir = "net20"; Framework="net-2.0"; Sign=$true}
|
||||
)
|
||||
}
|
||||
|
||||
@@ -51,10 +51,12 @@ task Build -depends Clean {
|
||||
{
|
||||
$name = $build.Name
|
||||
$finalDir = $build.FinalDir
|
||||
$sign = ($build.Sign -and $signAssemblies)
|
||||
|
||||
Write-Host -ForegroundColor Green "Building " $name
|
||||
Write-Host -ForegroundColor Green "Signed " $sign
|
||||
Write-Host
|
||||
exec { msbuild "/t:Clean;Rebuild" /p:Configuration=Release /p:OutputPath=bin\Release\$finalDir\ /p:AssemblyOriginatorKeyFile=$signKeyPath "/p:SignAssembly=$signAssemblies" (GetConstants $build.Constants $signAssemblies) ".\Src\$name.sln" } "Error building $name"
|
||||
exec { msbuild "/t:Clean;Rebuild" /p:Configuration=Release /p:OutputPath=bin\Release\$finalDir\ /p:AssemblyOriginatorKeyFile=$signKeyPath "/p:SignAssembly=$sign" (GetConstants $build.Constants $sign) ".\Src\$name.sln" } "Error building $name"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -137,28 +139,6 @@ task Test -depends Deploy {
|
||||
}
|
||||
}
|
||||
|
||||
function MergeAssembly($dllPrimaryAssembly, $signKey, [string[]]$mergedAssemlies)
|
||||
{
|
||||
$mergeAssemblyPaths = [String]::Join(" ", $mergedAssemlies)
|
||||
|
||||
$primary = Get-Item $dllPrimaryAssembly
|
||||
$mergedAssemblyName = $primary.Name
|
||||
$temporaryDir = $primary.DirectoryName + "\" + [Guid]::NewGuid().ToString()
|
||||
New-Item $temporaryDir -ItemType Directory
|
||||
|
||||
$ilMergeKeyFile = switch($signAssemblies) { $true { "/keyfile:$signKeyPath" } default { "" } }
|
||||
|
||||
try
|
||||
{
|
||||
exec { .\Tools\ILMerge\ilmerge.exe "/internalize" "/closed" "/log:$workingDir\$mergedAssemblyName.MergeLog.txt" $ilMergeKeyFile "/out:$temporaryDir\$mergedAssemblyName" $dllPrimaryAssembly $mergeAssemblyPaths } "Error executing ILMerge"
|
||||
Copy-Item -Path $temporaryDir\$mergedAssemblyName -Destination $dllPrimaryAssembly -Force
|
||||
}
|
||||
finally
|
||||
{
|
||||
Remove-Item $temporaryDir -Recurse -Force
|
||||
}
|
||||
}
|
||||
|
||||
function GetConstants($constants, $includeSigned)
|
||||
{
|
||||
$signed = switch($includeSigned) { $true { ";SIGNED" } default { "" } }
|
||||
|
||||
+3
-3
@@ -2,13 +2,13 @@ Versions:
|
||||
|
||||
Json.NET comes in different versions for the various .NET frameworks.
|
||||
|
||||
-DotNet:
|
||||
-Net40:
|
||||
.NET latest (4.0)
|
||||
|
||||
-DotNet35:
|
||||
-Net35:
|
||||
.NET 3.5 SP1, Mono
|
||||
|
||||
-DotNet20:
|
||||
-Net20:
|
||||
.NET 2.0
|
||||
|
||||
-Silverlight:
|
||||
|
||||
@@ -0,0 +1,114 @@
|
||||
#region License
|
||||
// Copyright (c) 2007 James Newton-King
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person
|
||||
// obtaining a copy of this software and associated documentation
|
||||
// files (the "Software"), to deal in the Software without
|
||||
// restriction, including without limitation the rights to use,
|
||||
// copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following
|
||||
// conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
// OTHER DEALINGS IN THE SOFTWARE.
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Newtonsoft.Json.Converters;
|
||||
using NUnit.Framework;
|
||||
using Newtonsoft.Json.Tests.TestObjects;
|
||||
|
||||
namespace Newtonsoft.Json.Tests.Converters
|
||||
{
|
||||
public class VersionClass
|
||||
{
|
||||
public VersionClass(string version1, string version2)
|
||||
{
|
||||
this.StringProperty1 = "StringProperty1";
|
||||
this.Version1 = new Version(version1);
|
||||
this.Version2 = new Version(version2);
|
||||
this.StringProperty2 = "StringProperty2";
|
||||
}
|
||||
|
||||
public VersionClass()
|
||||
{
|
||||
}
|
||||
|
||||
public string StringProperty1 { get; set; }
|
||||
public Version Version1 { get; set; }
|
||||
public Version Version2 { get; set; }
|
||||
public string StringProperty2 { get; set; }
|
||||
}
|
||||
|
||||
public class VersionConverterTests : TestFixtureBase
|
||||
{
|
||||
private void SerializeVersionClass(string version1, string version2)
|
||||
{
|
||||
VersionClass versionClass = new VersionClass(version1, version2);
|
||||
|
||||
string json = JsonConvert.SerializeObject(versionClass, Formatting.Indented, new VersionConverter());
|
||||
|
||||
string expectedJson = string.Format(@"{{
|
||||
""StringProperty1"": ""StringProperty1"",
|
||||
""Version1"": ""{0}"",
|
||||
""Version2"": ""{1}"",
|
||||
""StringProperty2"": ""StringProperty2""
|
||||
}}", version1, version2);
|
||||
|
||||
Assert.AreEqual(expectedJson, json);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SerializeVersionClass()
|
||||
{
|
||||
SerializeVersionClass("1.0.0.0", "2.0.0.0");
|
||||
SerializeVersionClass("1.2.0.0", "2.3.0.0");
|
||||
SerializeVersionClass("1.2.3.0", "2.3.4.0");
|
||||
SerializeVersionClass("1.2.3.4", "2.3.4.5");
|
||||
|
||||
SerializeVersionClass("1.2", "2.3");
|
||||
SerializeVersionClass("1.2.3", "2.3.4");
|
||||
SerializeVersionClass("1.2.3.4", "2.3.4.5");
|
||||
}
|
||||
|
||||
private void DeserializeVersionClass(string version1, string version2)
|
||||
{
|
||||
string json = string.Format(@"{{""StringProperty1"": ""StringProperty1"", ""Version1"": ""{0}"", ""Version2"": ""{1}"", ""StringProperty2"": ""StringProperty2""}}", version1, version2);
|
||||
Version expectedVersion1 = new Version(version1);
|
||||
Version expectedVersion2 = new Version(version2);
|
||||
|
||||
VersionClass versionClass = JsonConvert.DeserializeObject<VersionClass>(json, new VersionConverter());
|
||||
|
||||
Assert.AreEqual("StringProperty1", versionClass.StringProperty1);
|
||||
Assert.AreEqual(expectedVersion1, versionClass.Version1);
|
||||
Assert.AreEqual(expectedVersion2, versionClass.Version2);
|
||||
Assert.AreEqual("StringProperty2", versionClass.StringProperty2);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void DeserializeVersionClass()
|
||||
{
|
||||
DeserializeVersionClass("1.0.0.0", "2.0.0.0");
|
||||
DeserializeVersionClass("1.2.0.0", "2.3.0.0");
|
||||
DeserializeVersionClass("1.2.3.0", "2.3.4.0");
|
||||
DeserializeVersionClass("1.2.3.4", "2.3.4.5");
|
||||
|
||||
DeserializeVersionClass("1.2", "2.3");
|
||||
DeserializeVersionClass("1.2.3", "2.3.4");
|
||||
DeserializeVersionClass("1.2.3.4", "2.3.4.5");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1285,7 +1285,7 @@ namespace Newtonsoft.Json.Tests.Converters
|
||||
Assert.AreEqual(@"<?xml version=""1.0"" encoding=""utf-8""?><root booleanType=""true"" />", xmlString);
|
||||
}
|
||||
|
||||
static void JsonBodyToSoapXml(Stream json, Stream xml)
|
||||
private static void JsonBodyToSoapXml(Stream json, Stream xml)
|
||||
{
|
||||
Newtonsoft.Json.JsonSerializerSettings settings = new Newtonsoft.Json.JsonSerializerSettings();
|
||||
settings.Converters.Add(new Newtonsoft.Json.Converters.XmlNodeConverter());
|
||||
@@ -1301,6 +1301,494 @@ namespace Newtonsoft.Json.Tests.Converters
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if !NET20
|
||||
[Test]
|
||||
public void DeserializeXNodeDefaultNamespace()
|
||||
{
|
||||
string xaml = @"<Grid xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation"" xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml"" xmlns:toolkit=""clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"" Style=""{StaticResource trimFormGrid}"" x:Name=""TrimObjectForm"">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width=""63*"" />
|
||||
<ColumnDefinition Width=""320*"" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions xmlns="""">
|
||||
<RowDefinition />
|
||||
<RowDefinition />
|
||||
<RowDefinition />
|
||||
<RowDefinition />
|
||||
<RowDefinition />
|
||||
<RowDefinition />
|
||||
<RowDefinition />
|
||||
<RowDefinition />
|
||||
</Grid.RowDefinitions>
|
||||
<TextBox Style=""{StaticResource trimFormGrid_TB}"" Text=""{Binding TypedTitle, Converter={StaticResource trimPropertyConverter}}"" Name=""RecordTypedTitle"" Grid.Column=""1"" Grid.Row=""0"" xmlns="""" />
|
||||
<TextBox Style=""{StaticResource trimFormGrid_TB}"" Text=""{Binding ExternalReference, Converter={StaticResource trimPropertyConverter}}"" Name=""RecordExternalReference"" Grid.Column=""1"" Grid.Row=""1"" xmlns="""" />
|
||||
<toolkit:DatePicker Style=""{StaticResource trimFormGrid_DP}"" Value=""{Binding DateCreated, Converter={StaticResource trimPropertyConverter}}"" Name=""RecordDateCreated"" Grid.Column=""1"" Grid.Row=""2"" />
|
||||
<toolkit:DatePicker Style=""{StaticResource trimFormGrid_DP}"" Value=""{Binding DateDue, Converter={StaticResource trimPropertyConverter}}"" Name=""RecordDateDue"" Grid.Column=""1"" Grid.Row=""3"" />
|
||||
<TextBox Style=""{StaticResource trimFormGrid_TB}"" Text=""{Binding Author, Converter={StaticResource trimPropertyConverter}}"" Name=""RecordAuthor"" Grid.Column=""1"" Grid.Row=""4"" xmlns="""" />
|
||||
<TextBox Style=""{StaticResource trimFormGrid_TB}"" Text=""{Binding Container, Converter={StaticResource trimPropertyConverter}}"" Name=""RecordContainer"" Grid.Column=""1"" Grid.Row=""5"" xmlns="""" />
|
||||
<TextBox Style=""{StaticResource trimFormGrid_TB}"" Text=""{Binding IsEnclosed, Converter={StaticResource trimPropertyConverter}}"" Name=""RecordIsEnclosed"" Grid.Column=""1"" Grid.Row=""6"" xmlns="""" />
|
||||
<TextBox Style=""{StaticResource trimFormGrid_TB}"" Text=""{Binding Assignee, Converter={StaticResource trimPropertyConverter}}"" Name=""RecordAssignee"" Grid.Column=""1"" Grid.Row=""7"" xmlns="""" />
|
||||
<TextBlock Grid.Column=""0"" Text=""Title (Free Text Part)"" Style=""{StaticResource trimFormGrid_LBL}"" Grid.Row=""0"" xmlns="""" />
|
||||
<TextBlock Grid.Column=""0"" Text=""External ID"" Style=""{StaticResource trimFormGrid_LBL}"" Grid.Row=""1"" xmlns="""" />
|
||||
<TextBlock Grid.Column=""0"" Text=""Date Created"" Style=""{StaticResource trimFormGrid_LBL}"" Grid.Row=""2"" xmlns="""" />
|
||||
<TextBlock Grid.Column=""0"" Text=""Date Due"" Style=""{StaticResource trimFormGrid_LBL}"" Grid.Row=""3"" xmlns="""" />
|
||||
<TextBlock Grid.Column=""0"" Text=""Author"" Style=""{StaticResource trimFormGrid_LBL}"" Grid.Row=""4"" xmlns="""" />
|
||||
<TextBlock Grid.Column=""0"" Text=""Container"" Style=""{StaticResource trimFormGrid_LBL}"" Grid.Row=""5"" xmlns="""" />
|
||||
<TextBlock Grid.Column=""0"" Text=""Enclosed?"" Style=""{StaticResource trimFormGrid_LBL}"" Grid.Row=""6"" xmlns="""" />
|
||||
<TextBlock Grid.Column=""0"" Text=""Assignee"" Style=""{StaticResource trimFormGrid_LBL}"" Grid.Row=""7"" xmlns="""" />
|
||||
</Grid>";
|
||||
|
||||
string json = JsonConvert.SerializeXNode(XDocument.Parse(xaml), Formatting.Indented);
|
||||
|
||||
string expectedJson = @"{
|
||||
""Grid"": {
|
||||
""@xmlns"": ""http://schemas.microsoft.com/winfx/2006/xaml/presentation"",
|
||||
""@xmlns:x"": ""http://schemas.microsoft.com/winfx/2006/xaml"",
|
||||
""@xmlns:toolkit"": ""clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"",
|
||||
""@Style"": ""{StaticResource trimFormGrid}"",
|
||||
""@x:Name"": ""TrimObjectForm"",
|
||||
""Grid.ColumnDefinitions"": {
|
||||
""ColumnDefinition"": [
|
||||
{
|
||||
""@Width"": ""63*""
|
||||
},
|
||||
{
|
||||
""@Width"": ""320*""
|
||||
}
|
||||
]
|
||||
},
|
||||
""Grid.RowDefinitions"": {
|
||||
""@xmlns"": """",
|
||||
""RowDefinition"": [
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null
|
||||
]
|
||||
},
|
||||
""TextBox"": [
|
||||
{
|
||||
""@Style"": ""{StaticResource trimFormGrid_TB}"",
|
||||
""@Text"": ""{Binding TypedTitle, Converter={StaticResource trimPropertyConverter}}"",
|
||||
""@Name"": ""RecordTypedTitle"",
|
||||
""@Grid.Column"": ""1"",
|
||||
""@Grid.Row"": ""0"",
|
||||
""@xmlns"": """"
|
||||
},
|
||||
{
|
||||
""@Style"": ""{StaticResource trimFormGrid_TB}"",
|
||||
""@Text"": ""{Binding ExternalReference, Converter={StaticResource trimPropertyConverter}}"",
|
||||
""@Name"": ""RecordExternalReference"",
|
||||
""@Grid.Column"": ""1"",
|
||||
""@Grid.Row"": ""1"",
|
||||
""@xmlns"": """"
|
||||
},
|
||||
{
|
||||
""@Style"": ""{StaticResource trimFormGrid_TB}"",
|
||||
""@Text"": ""{Binding Author, Converter={StaticResource trimPropertyConverter}}"",
|
||||
""@Name"": ""RecordAuthor"",
|
||||
""@Grid.Column"": ""1"",
|
||||
""@Grid.Row"": ""4"",
|
||||
""@xmlns"": """"
|
||||
},
|
||||
{
|
||||
""@Style"": ""{StaticResource trimFormGrid_TB}"",
|
||||
""@Text"": ""{Binding Container, Converter={StaticResource trimPropertyConverter}}"",
|
||||
""@Name"": ""RecordContainer"",
|
||||
""@Grid.Column"": ""1"",
|
||||
""@Grid.Row"": ""5"",
|
||||
""@xmlns"": """"
|
||||
},
|
||||
{
|
||||
""@Style"": ""{StaticResource trimFormGrid_TB}"",
|
||||
""@Text"": ""{Binding IsEnclosed, Converter={StaticResource trimPropertyConverter}}"",
|
||||
""@Name"": ""RecordIsEnclosed"",
|
||||
""@Grid.Column"": ""1"",
|
||||
""@Grid.Row"": ""6"",
|
||||
""@xmlns"": """"
|
||||
},
|
||||
{
|
||||
""@Style"": ""{StaticResource trimFormGrid_TB}"",
|
||||
""@Text"": ""{Binding Assignee, Converter={StaticResource trimPropertyConverter}}"",
|
||||
""@Name"": ""RecordAssignee"",
|
||||
""@Grid.Column"": ""1"",
|
||||
""@Grid.Row"": ""7"",
|
||||
""@xmlns"": """"
|
||||
}
|
||||
],
|
||||
""toolkit:DatePicker"": [
|
||||
{
|
||||
""@Style"": ""{StaticResource trimFormGrid_DP}"",
|
||||
""@Value"": ""{Binding DateCreated, Converter={StaticResource trimPropertyConverter}}"",
|
||||
""@Name"": ""RecordDateCreated"",
|
||||
""@Grid.Column"": ""1"",
|
||||
""@Grid.Row"": ""2""
|
||||
},
|
||||
{
|
||||
""@Style"": ""{StaticResource trimFormGrid_DP}"",
|
||||
""@Value"": ""{Binding DateDue, Converter={StaticResource trimPropertyConverter}}"",
|
||||
""@Name"": ""RecordDateDue"",
|
||||
""@Grid.Column"": ""1"",
|
||||
""@Grid.Row"": ""3""
|
||||
}
|
||||
],
|
||||
""TextBlock"": [
|
||||
{
|
||||
""@Grid.Column"": ""0"",
|
||||
""@Text"": ""Title (Free Text Part)"",
|
||||
""@Style"": ""{StaticResource trimFormGrid_LBL}"",
|
||||
""@Grid.Row"": ""0"",
|
||||
""@xmlns"": """"
|
||||
},
|
||||
{
|
||||
""@Grid.Column"": ""0"",
|
||||
""@Text"": ""External ID"",
|
||||
""@Style"": ""{StaticResource trimFormGrid_LBL}"",
|
||||
""@Grid.Row"": ""1"",
|
||||
""@xmlns"": """"
|
||||
},
|
||||
{
|
||||
""@Grid.Column"": ""0"",
|
||||
""@Text"": ""Date Created"",
|
||||
""@Style"": ""{StaticResource trimFormGrid_LBL}"",
|
||||
""@Grid.Row"": ""2"",
|
||||
""@xmlns"": """"
|
||||
},
|
||||
{
|
||||
""@Grid.Column"": ""0"",
|
||||
""@Text"": ""Date Due"",
|
||||
""@Style"": ""{StaticResource trimFormGrid_LBL}"",
|
||||
""@Grid.Row"": ""3"",
|
||||
""@xmlns"": """"
|
||||
},
|
||||
{
|
||||
""@Grid.Column"": ""0"",
|
||||
""@Text"": ""Author"",
|
||||
""@Style"": ""{StaticResource trimFormGrid_LBL}"",
|
||||
""@Grid.Row"": ""4"",
|
||||
""@xmlns"": """"
|
||||
},
|
||||
{
|
||||
""@Grid.Column"": ""0"",
|
||||
""@Text"": ""Container"",
|
||||
""@Style"": ""{StaticResource trimFormGrid_LBL}"",
|
||||
""@Grid.Row"": ""5"",
|
||||
""@xmlns"": """"
|
||||
},
|
||||
{
|
||||
""@Grid.Column"": ""0"",
|
||||
""@Text"": ""Enclosed?"",
|
||||
""@Style"": ""{StaticResource trimFormGrid_LBL}"",
|
||||
""@Grid.Row"": ""6"",
|
||||
""@xmlns"": """"
|
||||
},
|
||||
{
|
||||
""@Grid.Column"": ""0"",
|
||||
""@Text"": ""Assignee"",
|
||||
""@Style"": ""{StaticResource trimFormGrid_LBL}"",
|
||||
""@Grid.Row"": ""7"",
|
||||
""@xmlns"": """"
|
||||
}
|
||||
]
|
||||
}
|
||||
}";
|
||||
|
||||
Assert.AreEqual(expectedJson, json);
|
||||
|
||||
XNode node = JsonConvert.DeserializeXNode(json);
|
||||
|
||||
string xaml2 = node.ToString();
|
||||
|
||||
string expectedXaml = @"<Grid xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation"" xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml"" xmlns:toolkit=""clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"" Style=""{StaticResource trimFormGrid}"" x:Name=""TrimObjectForm"">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width=""63*"" />
|
||||
<ColumnDefinition Width=""320*"" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions xmlns="""">
|
||||
<RowDefinition />
|
||||
<RowDefinition />
|
||||
<RowDefinition />
|
||||
<RowDefinition />
|
||||
<RowDefinition />
|
||||
<RowDefinition />
|
||||
<RowDefinition />
|
||||
<RowDefinition />
|
||||
</Grid.RowDefinitions>
|
||||
<TextBox Style=""{StaticResource trimFormGrid_TB}"" Text=""{Binding TypedTitle, Converter={StaticResource trimPropertyConverter}}"" Name=""RecordTypedTitle"" Grid.Column=""1"" Grid.Row=""0"" xmlns="""" />
|
||||
<TextBox Style=""{StaticResource trimFormGrid_TB}"" Text=""{Binding ExternalReference, Converter={StaticResource trimPropertyConverter}}"" Name=""RecordExternalReference"" Grid.Column=""1"" Grid.Row=""1"" xmlns="""" />
|
||||
<TextBox Style=""{StaticResource trimFormGrid_TB}"" Text=""{Binding Author, Converter={StaticResource trimPropertyConverter}}"" Name=""RecordAuthor"" Grid.Column=""1"" Grid.Row=""4"" xmlns="""" />
|
||||
<TextBox Style=""{StaticResource trimFormGrid_TB}"" Text=""{Binding Container, Converter={StaticResource trimPropertyConverter}}"" Name=""RecordContainer"" Grid.Column=""1"" Grid.Row=""5"" xmlns="""" />
|
||||
<TextBox Style=""{StaticResource trimFormGrid_TB}"" Text=""{Binding IsEnclosed, Converter={StaticResource trimPropertyConverter}}"" Name=""RecordIsEnclosed"" Grid.Column=""1"" Grid.Row=""6"" xmlns="""" />
|
||||
<TextBox Style=""{StaticResource trimFormGrid_TB}"" Text=""{Binding Assignee, Converter={StaticResource trimPropertyConverter}}"" Name=""RecordAssignee"" Grid.Column=""1"" Grid.Row=""7"" xmlns="""" />
|
||||
<toolkit:DatePicker Style=""{StaticResource trimFormGrid_DP}"" Value=""{Binding DateCreated, Converter={StaticResource trimPropertyConverter}}"" Name=""RecordDateCreated"" Grid.Column=""1"" Grid.Row=""2"" />
|
||||
<toolkit:DatePicker Style=""{StaticResource trimFormGrid_DP}"" Value=""{Binding DateDue, Converter={StaticResource trimPropertyConverter}}"" Name=""RecordDateDue"" Grid.Column=""1"" Grid.Row=""3"" />
|
||||
<TextBlock Grid.Column=""0"" Text=""Title (Free Text Part)"" Style=""{StaticResource trimFormGrid_LBL}"" Grid.Row=""0"" xmlns="""" />
|
||||
<TextBlock Grid.Column=""0"" Text=""External ID"" Style=""{StaticResource trimFormGrid_LBL}"" Grid.Row=""1"" xmlns="""" />
|
||||
<TextBlock Grid.Column=""0"" Text=""Date Created"" Style=""{StaticResource trimFormGrid_LBL}"" Grid.Row=""2"" xmlns="""" />
|
||||
<TextBlock Grid.Column=""0"" Text=""Date Due"" Style=""{StaticResource trimFormGrid_LBL}"" Grid.Row=""3"" xmlns="""" />
|
||||
<TextBlock Grid.Column=""0"" Text=""Author"" Style=""{StaticResource trimFormGrid_LBL}"" Grid.Row=""4"" xmlns="""" />
|
||||
<TextBlock Grid.Column=""0"" Text=""Container"" Style=""{StaticResource trimFormGrid_LBL}"" Grid.Row=""5"" xmlns="""" />
|
||||
<TextBlock Grid.Column=""0"" Text=""Enclosed?"" Style=""{StaticResource trimFormGrid_LBL}"" Grid.Row=""6"" xmlns="""" />
|
||||
<TextBlock Grid.Column=""0"" Text=""Assignee"" Style=""{StaticResource trimFormGrid_LBL}"" Grid.Row=""7"" xmlns="""" />
|
||||
</Grid>";
|
||||
|
||||
Assert.AreEqual(expectedXaml, xaml2);
|
||||
}
|
||||
#endif
|
||||
|
||||
[Test]
|
||||
public void DeserializeXmlNodeDefaultNamespace()
|
||||
{
|
||||
string xaml = @"<Grid xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation"" xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml"" xmlns:toolkit=""clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"" Style=""{StaticResource trimFormGrid}"" x:Name=""TrimObjectForm"">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width=""63*"" />
|
||||
<ColumnDefinition Width=""320*"" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions xmlns="""">
|
||||
<RowDefinition />
|
||||
<RowDefinition />
|
||||
<RowDefinition />
|
||||
<RowDefinition />
|
||||
<RowDefinition />
|
||||
<RowDefinition />
|
||||
<RowDefinition />
|
||||
<RowDefinition />
|
||||
</Grid.RowDefinitions>
|
||||
<TextBox Style=""{StaticResource trimFormGrid_TB}"" Text=""{Binding TypedTitle, Converter={StaticResource trimPropertyConverter}}"" Name=""RecordTypedTitle"" Grid.Column=""1"" Grid.Row=""0"" xmlns="""" />
|
||||
<TextBox Style=""{StaticResource trimFormGrid_TB}"" Text=""{Binding ExternalReference, Converter={StaticResource trimPropertyConverter}}"" Name=""RecordExternalReference"" Grid.Column=""1"" Grid.Row=""1"" xmlns="""" />
|
||||
<toolkit:DatePicker Style=""{StaticResource trimFormGrid_DP}"" Value=""{Binding DateCreated, Converter={StaticResource trimPropertyConverter}}"" Name=""RecordDateCreated"" Grid.Column=""1"" Grid.Row=""2"" />
|
||||
<toolkit:DatePicker Style=""{StaticResource trimFormGrid_DP}"" Value=""{Binding DateDue, Converter={StaticResource trimPropertyConverter}}"" Name=""RecordDateDue"" Grid.Column=""1"" Grid.Row=""3"" />
|
||||
<TextBox Style=""{StaticResource trimFormGrid_TB}"" Text=""{Binding Author, Converter={StaticResource trimPropertyConverter}}"" Name=""RecordAuthor"" Grid.Column=""1"" Grid.Row=""4"" xmlns="""" />
|
||||
<TextBox Style=""{StaticResource trimFormGrid_TB}"" Text=""{Binding Container, Converter={StaticResource trimPropertyConverter}}"" Name=""RecordContainer"" Grid.Column=""1"" Grid.Row=""5"" xmlns="""" />
|
||||
<TextBox Style=""{StaticResource trimFormGrid_TB}"" Text=""{Binding IsEnclosed, Converter={StaticResource trimPropertyConverter}}"" Name=""RecordIsEnclosed"" Grid.Column=""1"" Grid.Row=""6"" xmlns="""" />
|
||||
<TextBox Style=""{StaticResource trimFormGrid_TB}"" Text=""{Binding Assignee, Converter={StaticResource trimPropertyConverter}}"" Name=""RecordAssignee"" Grid.Column=""1"" Grid.Row=""7"" xmlns="""" />
|
||||
<TextBlock Grid.Column=""0"" Text=""Title (Free Text Part)"" Style=""{StaticResource trimFormGrid_LBL}"" Grid.Row=""0"" xmlns="""" />
|
||||
<TextBlock Grid.Column=""0"" Text=""External ID"" Style=""{StaticResource trimFormGrid_LBL}"" Grid.Row=""1"" xmlns="""" />
|
||||
<TextBlock Grid.Column=""0"" Text=""Date Created"" Style=""{StaticResource trimFormGrid_LBL}"" Grid.Row=""2"" xmlns="""" />
|
||||
<TextBlock Grid.Column=""0"" Text=""Date Due"" Style=""{StaticResource trimFormGrid_LBL}"" Grid.Row=""3"" xmlns="""" />
|
||||
<TextBlock Grid.Column=""0"" Text=""Author"" Style=""{StaticResource trimFormGrid_LBL}"" Grid.Row=""4"" xmlns="""" />
|
||||
<TextBlock Grid.Column=""0"" Text=""Container"" Style=""{StaticResource trimFormGrid_LBL}"" Grid.Row=""5"" xmlns="""" />
|
||||
<TextBlock Grid.Column=""0"" Text=""Enclosed?"" Style=""{StaticResource trimFormGrid_LBL}"" Grid.Row=""6"" xmlns="""" />
|
||||
<TextBlock Grid.Column=""0"" Text=""Assignee"" Style=""{StaticResource trimFormGrid_LBL}"" Grid.Row=""7"" xmlns="""" />
|
||||
</Grid>";
|
||||
|
||||
XmlDocument document = new XmlDocument();
|
||||
document.LoadXml(xaml);
|
||||
|
||||
string json = JsonConvert.SerializeXmlNode(document, Formatting.Indented);
|
||||
|
||||
string expectedJson = @"{
|
||||
""Grid"": {
|
||||
""@xmlns"": ""http://schemas.microsoft.com/winfx/2006/xaml/presentation"",
|
||||
""@xmlns:x"": ""http://schemas.microsoft.com/winfx/2006/xaml"",
|
||||
""@xmlns:toolkit"": ""clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"",
|
||||
""@Style"": ""{StaticResource trimFormGrid}"",
|
||||
""@x:Name"": ""TrimObjectForm"",
|
||||
""Grid.ColumnDefinitions"": {
|
||||
""ColumnDefinition"": [
|
||||
{
|
||||
""@Width"": ""63*""
|
||||
},
|
||||
{
|
||||
""@Width"": ""320*""
|
||||
}
|
||||
]
|
||||
},
|
||||
""Grid.RowDefinitions"": {
|
||||
""@xmlns"": """",
|
||||
""RowDefinition"": [
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null
|
||||
]
|
||||
},
|
||||
""TextBox"": [
|
||||
{
|
||||
""@Style"": ""{StaticResource trimFormGrid_TB}"",
|
||||
""@Text"": ""{Binding TypedTitle, Converter={StaticResource trimPropertyConverter}}"",
|
||||
""@Name"": ""RecordTypedTitle"",
|
||||
""@Grid.Column"": ""1"",
|
||||
""@Grid.Row"": ""0"",
|
||||
""@xmlns"": """"
|
||||
},
|
||||
{
|
||||
""@Style"": ""{StaticResource trimFormGrid_TB}"",
|
||||
""@Text"": ""{Binding ExternalReference, Converter={StaticResource trimPropertyConverter}}"",
|
||||
""@Name"": ""RecordExternalReference"",
|
||||
""@Grid.Column"": ""1"",
|
||||
""@Grid.Row"": ""1"",
|
||||
""@xmlns"": """"
|
||||
},
|
||||
{
|
||||
""@Style"": ""{StaticResource trimFormGrid_TB}"",
|
||||
""@Text"": ""{Binding Author, Converter={StaticResource trimPropertyConverter}}"",
|
||||
""@Name"": ""RecordAuthor"",
|
||||
""@Grid.Column"": ""1"",
|
||||
""@Grid.Row"": ""4"",
|
||||
""@xmlns"": """"
|
||||
},
|
||||
{
|
||||
""@Style"": ""{StaticResource trimFormGrid_TB}"",
|
||||
""@Text"": ""{Binding Container, Converter={StaticResource trimPropertyConverter}}"",
|
||||
""@Name"": ""RecordContainer"",
|
||||
""@Grid.Column"": ""1"",
|
||||
""@Grid.Row"": ""5"",
|
||||
""@xmlns"": """"
|
||||
},
|
||||
{
|
||||
""@Style"": ""{StaticResource trimFormGrid_TB}"",
|
||||
""@Text"": ""{Binding IsEnclosed, Converter={StaticResource trimPropertyConverter}}"",
|
||||
""@Name"": ""RecordIsEnclosed"",
|
||||
""@Grid.Column"": ""1"",
|
||||
""@Grid.Row"": ""6"",
|
||||
""@xmlns"": """"
|
||||
},
|
||||
{
|
||||
""@Style"": ""{StaticResource trimFormGrid_TB}"",
|
||||
""@Text"": ""{Binding Assignee, Converter={StaticResource trimPropertyConverter}}"",
|
||||
""@Name"": ""RecordAssignee"",
|
||||
""@Grid.Column"": ""1"",
|
||||
""@Grid.Row"": ""7"",
|
||||
""@xmlns"": """"
|
||||
}
|
||||
],
|
||||
""toolkit:DatePicker"": [
|
||||
{
|
||||
""@Style"": ""{StaticResource trimFormGrid_DP}"",
|
||||
""@Value"": ""{Binding DateCreated, Converter={StaticResource trimPropertyConverter}}"",
|
||||
""@Name"": ""RecordDateCreated"",
|
||||
""@Grid.Column"": ""1"",
|
||||
""@Grid.Row"": ""2""
|
||||
},
|
||||
{
|
||||
""@Style"": ""{StaticResource trimFormGrid_DP}"",
|
||||
""@Value"": ""{Binding DateDue, Converter={StaticResource trimPropertyConverter}}"",
|
||||
""@Name"": ""RecordDateDue"",
|
||||
""@Grid.Column"": ""1"",
|
||||
""@Grid.Row"": ""3""
|
||||
}
|
||||
],
|
||||
""TextBlock"": [
|
||||
{
|
||||
""@Grid.Column"": ""0"",
|
||||
""@Text"": ""Title (Free Text Part)"",
|
||||
""@Style"": ""{StaticResource trimFormGrid_LBL}"",
|
||||
""@Grid.Row"": ""0"",
|
||||
""@xmlns"": """"
|
||||
},
|
||||
{
|
||||
""@Grid.Column"": ""0"",
|
||||
""@Text"": ""External ID"",
|
||||
""@Style"": ""{StaticResource trimFormGrid_LBL}"",
|
||||
""@Grid.Row"": ""1"",
|
||||
""@xmlns"": """"
|
||||
},
|
||||
{
|
||||
""@Grid.Column"": ""0"",
|
||||
""@Text"": ""Date Created"",
|
||||
""@Style"": ""{StaticResource trimFormGrid_LBL}"",
|
||||
""@Grid.Row"": ""2"",
|
||||
""@xmlns"": """"
|
||||
},
|
||||
{
|
||||
""@Grid.Column"": ""0"",
|
||||
""@Text"": ""Date Due"",
|
||||
""@Style"": ""{StaticResource trimFormGrid_LBL}"",
|
||||
""@Grid.Row"": ""3"",
|
||||
""@xmlns"": """"
|
||||
},
|
||||
{
|
||||
""@Grid.Column"": ""0"",
|
||||
""@Text"": ""Author"",
|
||||
""@Style"": ""{StaticResource trimFormGrid_LBL}"",
|
||||
""@Grid.Row"": ""4"",
|
||||
""@xmlns"": """"
|
||||
},
|
||||
{
|
||||
""@Grid.Column"": ""0"",
|
||||
""@Text"": ""Container"",
|
||||
""@Style"": ""{StaticResource trimFormGrid_LBL}"",
|
||||
""@Grid.Row"": ""5"",
|
||||
""@xmlns"": """"
|
||||
},
|
||||
{
|
||||
""@Grid.Column"": ""0"",
|
||||
""@Text"": ""Enclosed?"",
|
||||
""@Style"": ""{StaticResource trimFormGrid_LBL}"",
|
||||
""@Grid.Row"": ""6"",
|
||||
""@xmlns"": """"
|
||||
},
|
||||
{
|
||||
""@Grid.Column"": ""0"",
|
||||
""@Text"": ""Assignee"",
|
||||
""@Style"": ""{StaticResource trimFormGrid_LBL}"",
|
||||
""@Grid.Row"": ""7"",
|
||||
""@xmlns"": """"
|
||||
}
|
||||
]
|
||||
}
|
||||
}";
|
||||
|
||||
Assert.AreEqual(expectedJson, json);
|
||||
|
||||
XmlNode node = JsonConvert.DeserializeXmlNode(json);
|
||||
|
||||
StringWriter sw = new StringWriter();
|
||||
XmlWriter writer = XmlWriter.Create(sw, new XmlWriterSettings
|
||||
{
|
||||
Indent = true,
|
||||
OmitXmlDeclaration = true
|
||||
});
|
||||
node.WriteTo(writer);
|
||||
writer.Flush();
|
||||
|
||||
string xaml2 = sw.ToString();
|
||||
|
||||
string expectedXaml = @"<Grid xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation"" xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml"" xmlns:toolkit=""clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"" Style=""{StaticResource trimFormGrid}"" x:Name=""TrimObjectForm"">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width=""63*"" />
|
||||
<ColumnDefinition Width=""320*"" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions xmlns="""">
|
||||
<RowDefinition />
|
||||
<RowDefinition />
|
||||
<RowDefinition />
|
||||
<RowDefinition />
|
||||
<RowDefinition />
|
||||
<RowDefinition />
|
||||
<RowDefinition />
|
||||
<RowDefinition />
|
||||
</Grid.RowDefinitions>
|
||||
<TextBox Style=""{StaticResource trimFormGrid_TB}"" Text=""{Binding TypedTitle, Converter={StaticResource trimPropertyConverter}}"" Name=""RecordTypedTitle"" Grid.Column=""1"" Grid.Row=""0"" xmlns="""" />
|
||||
<TextBox Style=""{StaticResource trimFormGrid_TB}"" Text=""{Binding ExternalReference, Converter={StaticResource trimPropertyConverter}}"" Name=""RecordExternalReference"" Grid.Column=""1"" Grid.Row=""1"" xmlns="""" />
|
||||
<TextBox Style=""{StaticResource trimFormGrid_TB}"" Text=""{Binding Author, Converter={StaticResource trimPropertyConverter}}"" Name=""RecordAuthor"" Grid.Column=""1"" Grid.Row=""4"" xmlns="""" />
|
||||
<TextBox Style=""{StaticResource trimFormGrid_TB}"" Text=""{Binding Container, Converter={StaticResource trimPropertyConverter}}"" Name=""RecordContainer"" Grid.Column=""1"" Grid.Row=""5"" xmlns="""" />
|
||||
<TextBox Style=""{StaticResource trimFormGrid_TB}"" Text=""{Binding IsEnclosed, Converter={StaticResource trimPropertyConverter}}"" Name=""RecordIsEnclosed"" Grid.Column=""1"" Grid.Row=""6"" xmlns="""" />
|
||||
<TextBox Style=""{StaticResource trimFormGrid_TB}"" Text=""{Binding Assignee, Converter={StaticResource trimPropertyConverter}}"" Name=""RecordAssignee"" Grid.Column=""1"" Grid.Row=""7"" xmlns="""" />
|
||||
<toolkit:DatePicker Style=""{StaticResource trimFormGrid_DP}"" Value=""{Binding DateCreated, Converter={StaticResource trimPropertyConverter}}"" Name=""RecordDateCreated"" Grid.Column=""1"" Grid.Row=""2"" />
|
||||
<toolkit:DatePicker Style=""{StaticResource trimFormGrid_DP}"" Value=""{Binding DateDue, Converter={StaticResource trimPropertyConverter}}"" Name=""RecordDateDue"" Grid.Column=""1"" Grid.Row=""3"" />
|
||||
<TextBlock Grid.Column=""0"" Text=""Title (Free Text Part)"" Style=""{StaticResource trimFormGrid_LBL}"" Grid.Row=""0"" xmlns="""" />
|
||||
<TextBlock Grid.Column=""0"" Text=""External ID"" Style=""{StaticResource trimFormGrid_LBL}"" Grid.Row=""1"" xmlns="""" />
|
||||
<TextBlock Grid.Column=""0"" Text=""Date Created"" Style=""{StaticResource trimFormGrid_LBL}"" Grid.Row=""2"" xmlns="""" />
|
||||
<TextBlock Grid.Column=""0"" Text=""Date Due"" Style=""{StaticResource trimFormGrid_LBL}"" Grid.Row=""3"" xmlns="""" />
|
||||
<TextBlock Grid.Column=""0"" Text=""Author"" Style=""{StaticResource trimFormGrid_LBL}"" Grid.Row=""4"" xmlns="""" />
|
||||
<TextBlock Grid.Column=""0"" Text=""Container"" Style=""{StaticResource trimFormGrid_LBL}"" Grid.Row=""5"" xmlns="""" />
|
||||
<TextBlock Grid.Column=""0"" Text=""Enclosed?"" Style=""{StaticResource trimFormGrid_LBL}"" Grid.Row=""6"" xmlns="""" />
|
||||
<TextBlock Grid.Column=""0"" Text=""Assignee"" Style=""{StaticResource trimFormGrid_LBL}"" Grid.Row=""7"" xmlns="""" />
|
||||
</Grid>";
|
||||
|
||||
Assert.AreEqual(expectedXaml, xaml2);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -1923,5 +1923,15 @@ bye", reader.Value);
|
||||
reader.Read();
|
||||
Assert.AreEqual(JsonToken.EndArray, reader.TokenType);
|
||||
}
|
||||
|
||||
[Test]
|
||||
[ExpectedException(typeof(JsonReaderException), ExpectedMessage = "Additional text encountered after finished reading JSON content: }. Line 1, position 2.")]
|
||||
public void UnexpectedEndTokenWhenParsingOddEndToken()
|
||||
{
|
||||
JsonReader reader = new JsonTextReader(new StringReader(@"{}}"));
|
||||
Assert.IsTrue(reader.Read());
|
||||
Assert.IsTrue(reader.Read());
|
||||
reader.Read();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -84,6 +84,7 @@
|
||||
<Compile Include="Converters\ObjectIdConverterTests.cs" />
|
||||
<Compile Include="Converters\RegexConverterTests.cs" />
|
||||
<Compile Include="Converters\StringEnumConverterTests.cs" />
|
||||
<Compile Include="Converters\VersionConverterTests.cs" />
|
||||
<Compile Include="JsonArrayAttributeTests.cs" />
|
||||
<Compile Include="ExceptionTests.cs" />
|
||||
<Compile Include="JsonValidatingReaderTests.cs" />
|
||||
|
||||
@@ -114,6 +114,7 @@
|
||||
<Compile Include="Converters\CustomCreationConverterTests.cs" />
|
||||
<Compile Include="Converters\ObjectIdConverterTests.cs" />
|
||||
<Compile Include="Converters\StringEnumConverterTests.cs" />
|
||||
<Compile Include="Converters\VersionConverterTests.cs" />
|
||||
<Compile Include="JsonArrayAttributeTests.cs" />
|
||||
<Compile Include="ExceptionTests.cs" />
|
||||
<Compile Include="JsonValidatingReaderTests.cs" />
|
||||
|
||||
@@ -110,6 +110,7 @@
|
||||
<Compile Include="Converters\ObjectIdConverterTests.cs" />
|
||||
<Compile Include="Converters\RegexConverterTests.cs" />
|
||||
<Compile Include="Converters\StringEnumConverterTests.cs" />
|
||||
<Compile Include="Converters\VersionConverterTests.cs" />
|
||||
<Compile Include="ExceptionTests.cs" />
|
||||
<Compile Include="JsonArrayAttributeTests.cs" />
|
||||
<Compile Include="Linq\ComponentModel\BindingTests.cs" />
|
||||
|
||||
@@ -74,6 +74,7 @@
|
||||
<Compile Include="Converters\ObjectIdConverterTests.cs" />
|
||||
<Compile Include="Converters\RegexConverterTests.cs" />
|
||||
<Compile Include="Converters\StringEnumConverterTests.cs" />
|
||||
<Compile Include="Converters\VersionConverterTests.cs" />
|
||||
<Compile Include="ExceptionTests.cs" />
|
||||
<Compile Include="JsonArrayAttributeTests.cs" />
|
||||
<Compile Include="Linq\ComponentModel\BindingTests.cs" />
|
||||
|
||||
@@ -115,6 +115,7 @@
|
||||
<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>
|
||||
|
||||
@@ -24,26 +24,32 @@
|
||||
#endregion
|
||||
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
|
||||
#if SILVERLIGHT
|
||||
[assembly: AssemblyTitle("Newtonsoft Json.NET Tests Silverlight")]
|
||||
#if WINDOWS_PHONE
|
||||
[assembly: AssemblyTitle("Json.NET Tests Windows Phone")]
|
||||
#elif SILVERLIGHT
|
||||
[assembly: AssemblyTitle("Json.NET Tests Silverlight")]
|
||||
#elif PocketPC
|
||||
[assembly: AssemblyTitle("Newtonsoft Json.NET Tests Compact")]
|
||||
[assembly: AssemblyTitle("Json.NET Tests Compact")]
|
||||
#elif NET20
|
||||
[assembly: AssemblyTitle("Json.NET Tests .NET 2.0")]
|
||||
#elif NET35
|
||||
[assembly: AssemblyTitle("Json.NET Tests .NET 3.5")]
|
||||
#else
|
||||
[assembly: AssemblyTitle("Newtonsoft Json.NET Tests")]
|
||||
[assembly: AssemblyTitle("Json.NET")]
|
||||
#endif
|
||||
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("Newtonsoft")]
|
||||
[assembly: AssemblyProduct("Newtonsoft Json.NET Tests")]
|
||||
[assembly: AssemblyCopyright("Copyright © Newtonsoft 2008")]
|
||||
[assembly: AssemblyProduct("Json.NET Tests")]
|
||||
[assembly: AssemblyCopyright("Copyright © James Newton-King 2008")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
@@ -64,7 +70,7 @@ using System.Runtime.InteropServices;
|
||||
//
|
||||
// You can specify all the values or you can default the Revision and Build Numbers
|
||||
// by using the '*' as shown below:
|
||||
[assembly: AssemblyVersion("4.0.7.0")]
|
||||
[assembly: AssemblyVersion("4.0.8.0")]
|
||||
#if !PocketPC
|
||||
[assembly: AssemblyFileVersion("4.0.7.14610")]
|
||||
[assembly: AssemblyFileVersion("4.0.8.14611")]
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,109 @@
|
||||
#region License
|
||||
// Copyright (c) 2007 James Newton-King
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person
|
||||
// obtaining a copy of this software and associated documentation
|
||||
// files (the "Software"), to deal in the Software without
|
||||
// restriction, including without limitation the rights to use,
|
||||
// copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following
|
||||
// conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
// OTHER DEALINGS IN THE SOFTWARE.
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Globalization;
|
||||
using Newtonsoft.Json.Utilities;
|
||||
|
||||
namespace Newtonsoft.Json.Converters
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts a <see cref="Version"/> to and from a string (e.g. "1.2.3.4").
|
||||
/// </summary>
|
||||
public class VersionConverter : JsonConverter
|
||||
{
|
||||
/// <summary>
|
||||
/// Writes the JSON representation of the object.
|
||||
/// </summary>
|
||||
/// <param name="writer">The <see cref="JsonWriter"/> to write to.</param>
|
||||
/// <param name="value">The value.</param>
|
||||
/// <param name="serializer">The calling serializer.</param>
|
||||
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
writer.WriteNull();
|
||||
}
|
||||
else if (value is Version)
|
||||
{
|
||||
writer.WriteValue(value.ToString());
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("Expected Version object value");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads the JSON representation of the object.
|
||||
/// </summary>
|
||||
/// <param name="reader">The <see cref="JsonReader"/> to read from.</param>
|
||||
/// <param name="objectType">Type of the object.</param>
|
||||
/// <param name="existingValue">The existing property value of the JSON that is being converted.</param>
|
||||
/// <param name="serializer">The calling serializer.</param>
|
||||
/// <returns>The object value.</returns>
|
||||
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
|
||||
{
|
||||
if (reader.TokenType == JsonToken.Null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (reader.TokenType == JsonToken.String)
|
||||
{
|
||||
try
|
||||
{
|
||||
Version v = new Version((string) reader.Value);
|
||||
return v;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception("Error parsing version string: {0}".FormatWith(CultureInfo.InvariantCulture, reader.Value), ex);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("Unexpected token or value when parsing version. Token: {0}, Value: {1}".FormatWith(CultureInfo.InvariantCulture, reader.TokenType, reader.Value));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether this instance can convert the specified object type.
|
||||
/// </summary>
|
||||
/// <param name="objectType">Type of the object.</param>
|
||||
/// <returns>
|
||||
/// <c>true</c> if this instance can convert the specified object type; otherwise, <c>false</c>.
|
||||
/// </returns>
|
||||
public override bool CanConvert(Type objectType)
|
||||
{
|
||||
return objectType == typeof (Version);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1426,9 +1426,11 @@ namespace Newtonsoft.Json.Converters
|
||||
|
||||
private IXmlElement CreateElement(string elementName, IXmlDocument document, string elementPrefix, XmlNamespaceManager manager)
|
||||
{
|
||||
return (!string.IsNullOrEmpty(elementPrefix))
|
||||
? document.CreateElement(elementName, manager.LookupNamespace(elementPrefix))
|
||||
: document.CreateElement(elementName);
|
||||
string ns = string.IsNullOrEmpty(elementPrefix) ? manager.DefaultNamespace : manager.LookupNamespace(elementPrefix);
|
||||
|
||||
IXmlElement element = (!string.IsNullOrEmpty(ns)) ? document.CreateElement(elementName, ns) : document.CreateElement(elementName);
|
||||
|
||||
return element;
|
||||
}
|
||||
|
||||
private void DeserializeNode(JsonReader reader, IXmlDocument document, XmlNamespaceManager manager, IXmlNode currentNode)
|
||||
|
||||
@@ -91,6 +91,7 @@
|
||||
<Compile Include="Converters\KeyValuePairConverter.cs" />
|
||||
<Compile Include="Converters\RegexConverter.cs" />
|
||||
<Compile Include="Converters\StringEnumConverter.cs" />
|
||||
<Compile Include="Converters\VersionConverter.cs" />
|
||||
<Compile Include="JsonConstructorAttribute.cs" />
|
||||
<Compile Include="Utilities\LinqBridge.cs" />
|
||||
<Compile Include="Linq\JPath.cs" />
|
||||
|
||||
@@ -103,6 +103,7 @@
|
||||
<Compile Include="Converters\RegexConverter.cs" />
|
||||
<Compile Include="Converters\StringEnumConverter.cs" />
|
||||
<Compile Include="ConstructorHandling.cs" />
|
||||
<Compile Include="Converters\VersionConverter.cs" />
|
||||
<Compile Include="JsonConstructorAttribute.cs" />
|
||||
<Compile Include="Linq\JPropertyDescriptor.cs" />
|
||||
<Compile Include="Utilities\DynamicProxy.cs" />
|
||||
|
||||
@@ -102,6 +102,7 @@
|
||||
<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="FormatterAssemblyStyle.cs" />
|
||||
<Compile Include="DefaultValueHandling.cs" />
|
||||
|
||||
@@ -75,6 +75,7 @@
|
||||
<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="FormatterAssemblyStyle.cs" />
|
||||
<Compile Include="DefaultValueHandling.cs" />
|
||||
|
||||
@@ -102,6 +102,7 @@
|
||||
<Compile Include="Converters\RegexConverter.cs" />
|
||||
<Compile Include="Converters\StringEnumConverter.cs" />
|
||||
<Compile Include="ConstructorHandling.cs" />
|
||||
<Compile Include="Converters\VersionConverter.cs" />
|
||||
<Compile Include="JsonConstructorAttribute.cs" />
|
||||
<Compile Include="Utilities\DynamicProxy.cs" />
|
||||
<Compile Include="Linq\JPath.cs" />
|
||||
|
||||
@@ -33,19 +33,19 @@ using System.Security;
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
#if WINDOWS_PHONE
|
||||
[assembly: AssemblyTitle("Newtonsoft Json.NET Windows Phone")]
|
||||
[assembly: AssemblyTitle("Json.NET Windows Phone")]
|
||||
#elif SILVERLIGHT
|
||||
[assembly: AssemblyTitle("Newtonsoft Json.NET Silverlight")]
|
||||
[assembly: AssemblyTitle("Json.NET Silverlight")]
|
||||
#elif PocketPC
|
||||
[assembly: AssemblyTitle("Newtonsoft Json.NET Compact")]
|
||||
[assembly: AssemblyTitle("Json.NET Compact")]
|
||||
#elif NET20
|
||||
[assembly: AssemblyTitle("Newtonsoft Json.NET .NET 2.0")]
|
||||
[assembly: AssemblyTitle("Json.NET .NET 2.0")]
|
||||
[assembly: AllowPartiallyTrustedCallers]
|
||||
#elif NET35
|
||||
[assembly: AssemblyTitle("Newtonsoft Json.NET .NET 3.5")]
|
||||
[assembly: AssemblyTitle("Json.NET .NET 3.5")]
|
||||
[assembly: AllowPartiallyTrustedCallers]
|
||||
#else
|
||||
[assembly: AssemblyTitle("Newtonsoft Json.NET")]
|
||||
[assembly: AssemblyTitle("Json.NET")]
|
||||
[assembly: AllowPartiallyTrustedCallers]
|
||||
#endif
|
||||
|
||||
@@ -57,11 +57,11 @@ using System.Security;
|
||||
|
||||
[assembly: InternalsVisibleTo("Newtonsoft.Json.Dynamic, PublicKey=0024000004800000940000000602000000240000525341310004000001000100cbd8d53b9d7de30f1f1278f636ec462cf9c254991291e66ebb157a885638a517887633b898ccbcf0d5c5ff7be85a6abe9e765d0ac7cd33c68dac67e7e64530e8222101109f154ab14a941c490ac155cd1d4fcba0fabb49016b4ef28593b015cab5937da31172f03f67d09edda404b88a60023f062ae71d0b2e4438b74cc11dc9")]
|
||||
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyDescription("Json.NET is a popular high-performance JSON framework for .NET")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("Newtonsoft")]
|
||||
[assembly: AssemblyProduct("Newtonsoft Json.NET")]
|
||||
[assembly: AssemblyCopyright("Copyright © Newtonsoft 2008")]
|
||||
[assembly: AssemblyProduct("Json.NET")]
|
||||
[assembly: AssemblyCopyright("Copyright © James Newton-King 2008")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
@@ -83,9 +83,9 @@ using System.Security;
|
||||
//
|
||||
// You can specify all the values or you can default the Revision and Build Numbers
|
||||
// by using the '*' as shown below:
|
||||
[assembly: AssemblyVersion("4.0.7.0")]
|
||||
[assembly: AssemblyVersion("4.0.8.0")]
|
||||
#if !PocketPC
|
||||
[assembly: AssemblyFileVersion("4.0.7.14610")]
|
||||
[assembly: AssemblyFileVersion("4.0.8.14611")]
|
||||
#endif
|
||||
|
||||
[assembly: CLSCompliant(true)]
|
||||
|
||||
Reference in New Issue
Block a user