-Documentation

This commit is contained in:
James Newton-King
2015-06-10 01:16:12 +12:00
parent f4e8c3d2ca
commit 08296c5eca
12 changed files with 120 additions and 16 deletions
+2 -1
View File
@@ -42,7 +42,7 @@ namespace Newtonsoft.Json.TestConsole
{
Console.WriteLine("Json.NET Test Console");
string version = FileVersionInfo.GetVersionInfo(typeof (JsonConvert).Assembly.Location).FileVersion;
string version = FileVersionInfo.GetVersionInfo(typeof(JsonConvert).Assembly.Location).FileVersion;
Console.WriteLine("Json.NET Version: " + version);
Console.ReadKey();
@@ -58,6 +58,7 @@ namespace Newtonsoft.Json.TestConsole
//ReadLargeJsonJavaScriptSerializer();
DiscriminatedUnionConverterTests t = new DiscriminatedUnionConverterTests();
t.SerializePerformance();
t.DeserializePerformance();
Console.WriteLine();
Console.WriteLine("Finished");
@@ -57,4 +57,4 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("7.0.0.0")]
[assembly: AssemblyFileVersion("7.0.1.18503")]
[assembly: AssemblyFileVersion("7.0.1.18610")]
@@ -101,7 +101,7 @@ namespace Newtonsoft.Json.Tests.Converters
Stopwatch ts = new Stopwatch();
ts.Start();
for (int i = 0; i < 2000; i++)
for (int i = 0; i < 10000; i++)
{
JsonConvert.SerializeObject(values);
}
@@ -127,7 +127,7 @@ namespace Newtonsoft.Json.Tests.Converters
Stopwatch ts = new Stopwatch();
ts.Start();
for (int i = 0; i < 2000; i++)
for (int i = 0; i < 10000; i++)
{
JsonConvert.DeserializeObject<List<Shape>>(json);
}
@@ -0,0 +1,76 @@
#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 JsonConstructor = Newtonsoft.Json.JsonConstructorAttribute;
namespace Newtonsoft.Json.Tests.Documentation.Samples.Serializer
{
[TestFixture]
public class JsonConstructorAttribute : TestFixtureBase
{
#region Types
public class User
{
public string UserName { get; private set; }
public bool Enabled { get; private set; }
public User()
{
}
[JsonConstructor]
public User(string userName, bool enabled)
{
UserName = userName;
Enabled = enabled;
}
}
#endregion
[Test]
public void Example()
{
#region Usage
string json = @"{
""UserName"": ""domain\\username"",
""Enabled"": true
}";
User user = JsonConvert.DeserializeObject<User>(json);
Console.WriteLine(user.UserName);
// domain\username
#endregion
Assert.AreEqual(@"domain\username", user.UserName);
}
}
}
@@ -170,6 +170,7 @@
<SubType>Code</SubType>
</Compile>
<Compile Include="Documentation\Samples\Serializer\DeserializeMetadataPropertyHandling.cs" />
<Compile Include="Documentation\Samples\Serializer\JsonConstructorAttribute.cs" />
<Compile Include="Documentation\Samples\Serializer\SerializeDateFormatString.cs" />
<Compile Include="Documentation\Samples\Serializer\DeserializeCollection.cs" />
<Compile Include="Documentation\Samples\Serializer\DeserializeConstructorHandling.cs" />
@@ -76,4 +76,4 @@ using System.Security;
// by using the '*' as shown below:
[assembly: AssemblyVersion("7.0.0.0")]
[assembly: AssemblyFileVersion("7.0.1.18503")]
[assembly: AssemblyFileVersion("7.0.1.18610")]
@@ -92,5 +92,5 @@ using System.Security;
// by using the '*' as shown below:
[assembly: AssemblyVersion("7.0.0.0")]
[assembly: AssemblyFileVersion("7.0.1.18503")]
[assembly: AssemblyFileVersion("7.0.1.18610")]
[assembly: CLSCompliant(true)]