PageRenderTime 120ms CodeModel.GetById 19ms app.highlight 77ms RepoModel.GetById 1ms app.codeStats 1ms

/Library/Newtonsoft.Json/Source/Src/Newtonsoft.Json.Tests/PerformanceTests.cs

https://github.com/DevChive/MvvmCross
C# | 890 lines | 785 code | 79 blank | 26 comment | 16 complexity | d2def3264b50a4316618da297e76cf6c MD5 | raw file
  1#region License
  2// Copyright (c) 2007 James Newton-King
  3//
  4// Permission is hereby granted, free of charge, to any person
  5// obtaining a copy of this software and associated documentation
  6// files (the "Software"), to deal in the Software without
  7// restriction, including without limitation the rights to use,
  8// copy, modify, merge, publish, distribute, sublicense, and/or sell
  9// copies of the Software, and to permit persons to whom the
 10// Software is furnished to do so, subject to the following
 11// conditions:
 12//
 13// The above copyright notice and this permission notice shall be
 14// included in all copies or substantial portions of the Software.
 15//
 16// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 17// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
 18// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 19// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
 20// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
 21// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 22// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 23// OTHER DEALINGS IN THE SOFTWARE.
 24#endregion
 25
 26#if !(SILVERLIGHT || PocketPC || NET20 || NET35 || NETFX_CORE || PORTABLE)
 27using System;
 28using System.Collections.Generic;
 29using System.Globalization;
 30using System.Diagnostics;
 31using System.IO;
 32using System.Linq;
 33using System.Runtime.Serialization;
 34using System.Web.Script.Serialization;
 35using System.Xml.Linq;
 36using System.Xml.Serialization;
 37using Newtonsoft.Json.Utilities;
 38using NUnit.Framework;
 39using System.Runtime.Serialization.Json;
 40using System.Text;
 41using Newtonsoft.Json.Bson;
 42using System.Runtime.Serialization.Formatters.Binary;
 43using Newtonsoft.Json.Linq;
 44using Newtonsoft.Json.Converters;
 45
 46namespace Newtonsoft.Json.Tests
 47{
 48  [Serializable]
 49  [DataContract]
 50  public class Image
 51  {
 52    [DataMember]
 53    public string FileName { get; set; }
 54
 55    [DataMember]
 56    public string Author { get; set; }
 57
 58    [DataMember]
 59    public string Caption { get; set; }
 60
 61    [DataMember]
 62    public byte[] Data { get; set; }
 63  }
 64
 65  [TestFixture]
 66  public class PerformanceTests : TestFixtureBase
 67  {
 68    private const int Iterations = 100;
 69    //private const int Iterations = 5000;
 70
 71#region Data
 72
 73    private const string BsonHex =
 74      @"A9-01-00-00-04-73-74-72-69-6E-67-73-00-2B-00-00-00-0A-30-00-02-31-00-19-00-00-00-4D-61-72-6B-75-73-20-65-67-67-65-72-20-5D-3E-3C-5B-2C-20-28-32-6E-64-29-00-0A-32-00-00-03-64-69-63-74-69-6F-6E-61-72-79-00-37-00-00-00-10-56-61-6C-20-26-20-61-73-64-31-00-01-00-00-00-10-56-61-6C-32-20-26-20-61-73-64-31-00-03-00-00-00-10-56-61-6C-33-20-26-20-61-73-64-31-00-04-00-00-00-00-02-4E-61-6D-65-00-05-00-00-00-52-69-63-6B-00-09-4E-6F-77-00-EF-BD-69-EC-25-01-00-00-01-42-69-67-4E-75-6D-62-65-72-00-E7-7B-CC-26-96-C7-1F-42-03-41-64-64-72-65-73-73-31-00-47-00-00-00-02-53-74-72-65-65-74-00-0B-00-00-00-66-66-66-20-53-74-72-65-65-74-00-02-50-68-6F-6E-65-00-0F-00-00-00-28-35-30-33-29-20-38-31-34-2D-36-33-33-35-00-09-45-6E-74-65-72-65-64-00-6F-FF-31-53-26-01-00-00-00-04-41-64-64-72-65-73-73-65-73-00-A2-00-00-00-03-30-00-4B-00-00-00-02-53-74-72-65-65-74-00-0F-00-00-00-1F-61-72-72-61-79-3C-61-64-64-72-65-73-73-00-02-50-68-6F-6E-65-00-0F-00-00-00-28-35-30-33-29-20-38-31-34-2D-36-33-33-35-00-09-45-6E-74-65-72-65-64-00-6F-73-0C-E7-25-01-00-00-00-03-31-00-4C-00-00-00-02-53-74-72-65-65-74-00-10-00-00-00-61-72-72-61-79-20-32-20-61-64-64-72-65-73-73-00-02-50-68-6F-6E-65-00-0F-00-00-00-28-35-30-33-29-20-38-31-34-2D-36-33-33-35-00-09-45-6E-74-65-72-65-64-00-6F-17-E6-E1-25-01-00-00-00-00-00";
 75
 76    private const string BinaryFormatterHex =
 77      @"00-01-00-00-00-FF-FF-FF-FF-01-00-00-00-00-00-00-00-0C-02-00-00-00-4C-4E-65-77-74-6F-6E-73-6F-66-74-2E-4A-73-6F-6E-2E-54-65-73-74-73-2C-20-56-65-72-73-69-6F-6E-3D-33-2E-35-2E-30-2E-30-2C-20-43-75-6C-74-75-72-65-3D-6E-65-75-74-72-61-6C-2C-20-50-75-62-6C-69-63-4B-65-79-54-6F-6B-65-6E-3D-6E-75-6C-6C-05-01-00-00-00-1F-4E-65-77-74-6F-6E-73-6F-66-74-2E-4A-73-6F-6E-2E-54-65-73-74-73-2E-54-65-73-74-43-6C-61-73-73-07-00-00-00-05-5F-4E-61-6D-65-04-5F-4E-6F-77-0A-5F-42-69-67-4E-75-6D-62-65-72-09-5F-41-64-64-72-65-73-73-31-0A-5F-41-64-64-72-65-73-73-65-73-07-73-74-72-69-6E-67-73-0A-64-69-63-74-69-6F-6E-61-72-79-01-00-00-04-03-03-03-0D-05-1D-4E-65-77-74-6F-6E-73-6F-66-74-2E-4A-73-6F-6E-2E-54-65-73-74-73-2E-41-64-64-72-65-73-73-02-00-00-00-90-01-53-79-73-74-65-6D-2E-43-6F-6C-6C-65-63-74-69-6F-6E-73-2E-47-65-6E-65-72-69-63-2E-4C-69-73-74-60-31-5B-5B-4E-65-77-74-6F-6E-73-6F-66-74-2E-4A-73-6F-6E-2E-54-65-73-74-73-2E-41-64-64-72-65-73-73-2C-20-4E-65-77-74-6F-6E-73-6F-66-74-2E-4A-73-6F-6E-2E-54-65-73-74-73-2C-20-56-65-72-73-69-6F-6E-3D-33-2E-35-2E-30-2E-30-2C-20-43-75-6C-74-75-72-65-3D-6E-65-75-74-72-61-6C-2C-20-50-75-62-6C-69-63-4B-65-79-54-6F-6B-65-6E-3D-6E-75-6C-6C-5D-5D-7F-53-79-73-74-65-6D-2E-43-6F-6C-6C-65-63-74-69-6F-6E-73-2E-47-65-6E-65-72-69-63-2E-4C-69-73-74-60-31-5B-5B-53-79-73-74-65-6D-2E-53-74-72-69-6E-67-2C-20-6D-73-63-6F-72-6C-69-62-2C-20-56-65-72-73-69-6F-6E-3D-32-2E-30-2E-30-2E-30-2C-20-43-75-6C-74-75-72-65-3D-6E-65-75-74-72-61-6C-2C-20-50-75-62-6C-69-63-4B-65-79-54-6F-6B-65-6E-3D-62-37-37-61-35-63-35-36-31-39-33-34-65-30-38-39-5D-5D-E1-01-53-79-73-74-65-6D-2E-43-6F-6C-6C-65-63-74-69-6F-6E-73-2E-47-65-6E-65-72-69-63-2E-44-69-63-74-69-6F-6E-61-72-79-60-32-5B-5B-53-79-73-74-65-6D-2E-53-74-72-69-6E-67-2C-20-6D-73-63-6F-72-6C-69-62-2C-20-56-65-72-73-69-6F-6E-3D-32-2E-30-2E-30-2E-30-2C-20-43-75-6C-74-75-72-65-3D-6E-65-75-74-72-61-6C-2C-20-50-75-62-6C-69-63-4B-65-79-54-6F-6B-65-6E-3D-62-37-37-61-35-63-35-36-31-39-33-34-65-30-38-39-5D-2C-5B-53-79-73-74-65-6D-2E-49-6E-74-33-32-2C-20-6D-73-63-6F-72-6C-69-62-2C-20-56-65-72-73-69-6F-6E-3D-32-2E-30-2E-30-2E-30-2C-20-43-75-6C-74-75-72-65-3D-6E-65-75-74-72-61-6C-2C-20-50-75-62-6C-69-63-4B-65-79-54-6F-6B-65-6E-3D-62-37-37-61-35-63-35-36-31-39-33-34-65-30-38-39-5D-5D-02-00-00-00-06-03-00-00-00-04-52-69-63-6B-B6-25-3A-D1-C5-59-CC-88-0F-33-34-31-32-33-31-32-33-31-32-33-2E-31-32-31-09-04-00-00-00-09-05-00-00-00-09-06-00-00-00-09-07-00-00-00-05-04-00-00-00-1D-4E-65-77-74-6F-6E-73-6F-66-74-2E-4A-73-6F-6E-2E-54-65-73-74-73-2E-41-64-64-72-65-73-73-03-00-00-00-07-5F-73-74-72-65-65-74-06-5F-50-68-6F-6E-65-08-5F-45-6E-74-65-72-65-64-01-01-00-0D-02-00-00-00-06-08-00-00-00-0A-66-66-66-20-53-74-72-65-65-74-06-09-00-00-00-0E-28-35-30-33-29-20-38-31-34-2D-36-33-33-35-B6-BD-B8-BF-74-69-CC-88-04-05-00-00-00-90-01-53-79-73-74-65-6D-2E-43-6F-6C-6C-65-63-74-69-6F-6E-73-2E-47-65-6E-65-72-69-63-2E-4C-69-73-74-60-31-5B-5B-4E-65-77-74-6F-6E-73-6F-66-74-2E-4A-73-6F-6E-2E-54-65-73-74-73-2E-41-64-64-72-65-73-73-2C-20-4E-65-77-74-6F-6E-73-6F-66-74-2E-4A-73-6F-6E-2E-54-65-73-74-73-2C-20-56-65-72-73-69-6F-6E-3D-33-2E-35-2E-30-2E-30-2C-20-43-75-6C-74-75-72-65-3D-6E-65-75-74-72-61-6C-2C-20-50-75-62-6C-69-63-4B-65-79-54-6F-6B-65-6E-3D-6E-75-6C-6C-5D-5D-03-00-00-00-06-5F-69-74-65-6D-73-05-5F-73-69-7A-65-08-5F-76-65-72-73-69-6F-6E-04-00-00-1F-4E-65-77-74-6F-6E-73-6F-66-74-2E-4A-73-6F-6E-2E-54-65-73-74-73-2E-41-64-64-72-65-73-73-5B-5D-02-00-00-00-08-08-09-0A-00-00-00-02-00-00-00-02-00-00-00-04-06-00-00-00-7F-53-79-73-74-65-6D-2E-43-6F-6C-6C-65-63-74-69-6F-6E-73-2E-47-65-6E-65-72-69-63-2E-4C-69-73-74-60-31-5B-5B-53-79-73-74-65-6D-2E-53-74-72-69-6E-67-2C-20-6D-73-63-6F-72-6C-69-62-2C-20-56-65-72-73-69-6F-6E-3D-32-2E-30-2E-30-2E-30-2C-20-43-75-6C-74-75-72-65-3D-6E-65-75-74-72-61-6C-2C-20-50-75-62-6C-69-63-4B-65-79-54-6F-6B-65-6E-3D-62-37-37-61-35-63-35-36-31-39-33-34-65-30-38-39-5D-5D-03-00-00-00-06-5F-69-74-65-6D-73-05-5F-73-69-7A-65-08-5F-76-65-72-73-69-6F-6E-06-00-00-08-08-09-0B-00-00-00-03-00-00-00-03-00-00-00-04-07-00-00-00-E1-01-53-79-73-74-65-6D-2E-43-6F-6C-6C-65-63-74-69-6F-6E-73-2E-47-65-6E-65-72-69-63-2E-44-69-63-74-69-6F-6E-61-72-79-60-32-5B-5B-53-79-73-74-65-6D-2E-53-74-72-69-6E-67-2C-20-6D-73-63-6F-72-6C-69-62-2C-20-56-65-72-73-69-6F-6E-3D-32-2E-30-2E-30-2E-30-2C-20-43-75-6C-74-75-72-65-3D-6E-65-75-74-72-61-6C-2C-20-50-75-62-6C-69-63-4B-65-79-54-6F-6B-65-6E-3D-62-37-37-61-35-63-35-36-31-39-33-34-65-30-38-39-5D-2C-5B-53-79-73-74-65-6D-2E-49-6E-74-33-32-2C-20-6D-73-63-6F-72-6C-69-62-2C-20-56-65-72-73-69-6F-6E-3D-32-2E-30-2E-30-2E-30-2C-20-43-75-6C-74-75-72-65-3D-6E-65-75-74-72-61-6C-2C-20-50-75-62-6C-69-63-4B-65-79-54-6F-6B-65-6E-3D-62-37-37-61-35-63-35-36-31-39-33-34-65-30-38-39-5D-5D-04-00-00-00-07-56-65-72-73-69-6F-6E-08-43-6F-6D-70-61-72-65-72-08-48-61-73-68-53-69-7A-65-0D-4B-65-79-56-61-6C-75-65-50-61-69-72-73-00-03-00-03-08-92-01-53-79-73-74-65-6D-2E-43-6F-6C-6C-65-63-74-69-6F-6E-73-2E-47-65-6E-65-72-69-63-2E-47-65-6E-65-72-69-63-45-71-75-61-6C-69-74-79-43-6F-6D-70-61-72-65-72-60-31-5B-5B-53-79-73-74-65-6D-2E-53-74-72-69-6E-67-2C-20-6D-73-63-6F-72-6C-69-62-2C-20-56-65-72-73-69-6F-6E-3D-32-2E-30-2E-30-2E-30-2C-20-43-75-6C-74-75-72-65-3D-6E-65-75-74-72-61-6C-2C-20-50-75-62-6C-69-63-4B-65-79-54-6F-6B-65-6E-3D-62-37-37-61-35-63-35-36-31-39-33-34-65-30-38-39-5D-5D-08-E5-01-53-79-73-74-65-6D-2E-43-6F-6C-6C-65-63-74-69-6F-6E-73-2E-47-65-6E-65-72-69-63-2E-4B-65-79-56-61-6C-75-65-50-61-69-72-60-32-5B-5B-53-79-73-74-65-6D-2E-53-74-72-69-6E-67-2C-20-6D-73-63-6F-72-6C-69-62-2C-20-56-65-72-73-69-6F-6E-3D-32-2E-30-2E-30-2E-30-2C-20-43-75-6C-74-75-72-65-3D-6E-65-75-74-72-61-6C-2C-20-50-75-62-6C-69-63-4B-65-79-54-6F-6B-65-6E-3D-62-37-37-61-35-63-35-36-31-39-33-34-65-30-38-39-5D-2C-5B-53-79-73-74-65-6D-2E-49-6E-74-33-32-2C-20-6D-73-63-6F-72-6C-69-62-2C-20-56-65-72-73-69-6F-6E-3D-32-2E-30-2E-30-2E-30-2C-20-43-75-6C-74-75-72-65-3D-6E-65-75-74-72-61-6C-2C-20-50-75-62-6C-69-63-4B-65-79-54-6F-6B-65-6E-3D-62-37-37-61-35-63-35-36-31-39-33-34-65-30-38-39-5D-5D-5B-5D-03-00-00-00-09-0C-00-00-00-03-00-00-00-09-0D-00-00-00-07-0A-00-00-00-00-01-00-00-00-04-00-00-00-04-1D-4E-65-77-74-6F-6E-73-6F-66-74-2E-4A-73-6F-6E-2E-54-65-73-74-73-2E-41-64-64-72-65-73-73-02-00-00-00-09-0E-00-00-00-09-0F-00-00-00-0D-02-11-0B-00-00-00-04-00-00-00-0A-06-10-00-00-00-18-4D-61-72-6B-75-73-20-65-67-67-65-72-20-5D-3E-3C-5B-2C-20-28-32-6E-64-29-0D-02-04-0C-00-00-00-92-01-53-79-73-74-65-6D-2E-43-6F-6C-6C-65-63-74-69-6F-6E-73-2E-47-65-6E-65-72-69-63-2E-47-65-6E-65-72-69-63-45-71-75-61-6C-69-74-79-43-6F-6D-70-61-72-65-72-60-31-5B-5B-53-79-73-74-65-6D-2E-53-74-72-69-6E-67-2C-20-6D-73-63-6F-72-6C-69-62-2C-20-56-65-72-73-69-6F-6E-3D-32-2E-30-2E-30-2E-30-2C-20-43-75-6C-74-75-72-65-3D-6E-65-75-74-72-61-6C-2C-20-50-75-62-6C-69-63-4B-65-79-54-6F-6B-65-6E-3D-62-37-37-61-35-63-35-36-31-39-33-34-65-30-38-39-5D-5D-00-00-00-00-07-0D-00-00-00-00-01-00-00-00-03-00-00-00-03-E3-01-53-79-73-74-65-6D-2E-43-6F-6C-6C-65-63-74-69-6F-6E-73-2E-47-65-6E-65-72-69-63-2E-4B-65-79-56-61-6C-75-65-50-61-69-72-60-32-5B-5B-53-79-73-74-65-6D-2E-53-74-72-69-6E-67-2C-20-6D-73-63-6F-72-6C-69-62-2C-20-56-65-72-73-69-6F-6E-3D-32-2E-30-2E-30-2E-30-2C-20-43-75-6C-74-75-72-65-3D-6E-65-75-74-72-61-6C-2C-20-50-75-62-6C-69-63-4B-65-79-54-6F-6B-65-6E-3D-62-37-37-61-35-63-35-36-31-39-33-34-65-30-38-39-5D-2C-5B-53-79-73-74-65-6D-2E-49-6E-74-33-32-2C-20-6D-73-63-6F-72-6C-69-62-2C-20-56-65-72-73-69-6F-6E-3D-32-2E-30-2E-30-2E-30-2C-20-43-75-6C-74-75-72-65-3D-6E-65-75-74-72-61-6C-2C-20-50-75-62-6C-69-63-4B-65-79-54-6F-6B-65-6E-3D-62-37-37-61-35-63-35-36-31-39-33-34-65-30-38-39-5D-5D-04-EF-FF-FF-FF-E3-01-53-79-73-74-65-6D-2E-43-6F-6C-6C-65-63-74-69-6F-6E-73-2E-47-65-6E-65-72-69-63-2E-4B-65-79-56-61-6C-75-65-50-61-69-72-60-32-5B-5B-53-79-73-74-65-6D-2E-53-74-72-69-6E-67-2C-20-6D-73-63-6F-72-6C-69-62-2C-20-56-65-72-73-69-6F-6E-3D-32-2E-30-2E-30-2E-30-2C-20-43-75-6C-74-75-72-65-3D-6E-65-75-74-72-61-6C-2C-20-50-75-62-6C-69-63-4B-65-79-54-6F-6B-65-6E-3D-62-37-37-61-35-63-35-36-31-39-33-34-65-30-38-39-5D-2C-5B-53-79-73-74-65-6D-2E-49-6E-74-33-32-2C-20-6D-73-63-6F-72-6C-69-62-2C-20-56-65-72-73-69-6F-6E-3D-32-2E-30-2E-30-2E-30-2C-20-43-75-6C-74-75-72-65-3D-6E-65-75-74-72-61-6C-2C-20-50-75-62-6C-69-63-4B-65-79-54-6F-6B-65-6E-3D-62-37-37-61-35-63-35-36-31-39-33-34-65-30-38-39-5D-5D-02-00-00-00-03-6B-65-79-05-76-61-6C-75-65-01-00-08-06-12-00-00-00-0A-56-61-6C-20-26-20-61-73-64-31-01-00-00-00-01-ED-FF-FF-FF-EF-FF-FF-FF-06-14-00-00-00-0B-56-61-6C-32-20-26-20-61-73-64-31-03-00-00-00-01-EB-FF-FF-FF-EF-FF-FF-FF-06-16-00-00-00-0B-56-61-6C-33-20-26-20-61-73-64-31-04-00-00-00-01-0E-00-00-00-04-00-00-00-06-17-00-00-00-0E-1F-61-72-72-61-79-3C-61-64-64-72-65-73-73-09-09-00-00-00-B6-FD-0B-45-F4-58-CC-88-01-0F-00-00-00-04-00-00-00-06-19-00-00-00-0F-61-72-72-61-79-20-32-20-61-64-64-72-65-73-73-09-09-00-00-00-B6-3D-A2-1A-2B-58-CC-88-0B";
 78
 79    private const string XmlText =
 80      @"<TestClass xmlns=""http://schemas.datacontract.org/2004/07/Newtonsoft.Json.Tests"" xmlns:i=""http://www.w3.org/2001/XMLSchema-instance""><Address1><Entered>2010-01-21T11:12:16.0809174+13:00</Entered><Phone>(503) 814-6335</Phone><Street>fff Street</Street></Address1><Addresses><Address><Entered>2009-12-31T11:12:16.0809174+13:00</Entered><Phone>(503) 814-6335</Phone><Street>&#x1F;array&lt;address</Street></Address><Address><Entered>2009-12-30T11:12:16.0809174+13:00</Entered><Phone>(503) 814-6335</Phone><Street>array 2 address</Street></Address></Addresses><BigNumber>34123123123.121</BigNumber><Name>Rick</Name><Now>2010-01-01T12:12:16.0809174+13:00</Now><dictionary xmlns:a=""http://schemas.microsoft.com/2003/10/Serialization/Arrays""><a:KeyValueOfstringint><a:Key>Val &amp; asd1</a:Key><a:Value>1</a:Value></a:KeyValueOfstringint><a:KeyValueOfstringint><a:Key>Val2 &amp; asd1</a:Key><a:Value>3</a:Value></a:KeyValueOfstringint><a:KeyValueOfstringint><a:Key>Val3 &amp; asd1</a:Key><a:Value>4</a:Value></a:KeyValueOfstringint></dictionary><strings xmlns:a=""http://schemas.microsoft.com/2003/10/Serialization/Arrays""><a:string i:nil=""true""/><a:string>Markus egger ]&gt;&lt;[, (2nd)</a:string><a:string i:nil=""true""/></strings></TestClass>";
 81
 82    private const string JsonText =
 83      @"{""strings"":[null,""Markus egger ]><[, (2nd)"",null],""dictionary"":{""Val & asd1"":1,""Val2 & asd1"":3,""Val3 & asd1"":4},""Name"":""Rick"",""Now"":""\/Date(1262301136080+1300)\/"",""BigNumber"":34123123123.121,""Address1"":{""Street"":""fff Street"",""Phone"":""(503) 814-6335"",""Entered"":""\/Date(1264025536080+1300)\/""},""Addresses"":[{""Street"":""\u001farray<address"",""Phone"":""(503) 814-6335"",""Entered"":""\/Date(1262211136080+1300)\/""},{""Street"":""array 2 address"",""Phone"":""(503) 814-6335"",""Entered"":""\/Date(1262124736080+1300)\/""}]}";
 84
 85    private const string JsonIsoText =
 86      @"{""strings"":[null,""Markus egger ]><[, (2nd)"",null],""dictionary"":{""Val & asd1"":1,""Val2 & asd1"":3,""Val3 & asd1"":4},""Name"":""Rick"",""Now"":""2012-02-25T19:55:50.6095676+13:00"",""BigNumber"":34123123123.121,""Address1"":{""Street"":""fff Street"",""Phone"":""(503) 814-6335"",""Entered"":""2012-02-24T18:55:50.6095676+13:00""},""Addresses"":[{""Street"":""\u001farray<address"",""Phone"":""(503) 814-6335"",""Entered"":""2012-02-24T18:55:50.6095676+13:00""},{""Street"":""array 2 address"",""Phone"":""(503) 814-6335"",""Entered"":""2012-02-24T18:55:50.6095676+13:00""}]}";
 87
 88    private const string SimpleJsonText =
 89      @"{""Id"":2311,""Name"":""Simple-1"",""Address"":""Planet Earth"",""Scores"":[82,96,49,40,38,38,78,96,2,39]}";
 90
 91    public enum SerializeMethod
 92    {
 93      JsonNet,
 94      JsonNetWithIsoConverter,
 95      JsonNetBinary,
 96      BinaryFormatter,
 97      JavaScriptSerializer,
 98      DataContractSerializer,
 99      DataContractJsonSerializer
100    }
101
102    #endregion
103
104    [Test]
105    public void SerializeSimpleObject()
106    {
107      var value = CreateSimpleObject();
108
109      SerializeTests(value);
110    }
111
112    [Test]
113    public void DeserializeSimpleObject()
114    {
115      DeserializeTests<SimpleObject>(SimpleJsonText);
116    }
117
118    [Test]
119    public void Serialize()
120    {
121      TestClass test = CreateSerializationObject();
122
123      SerializeTests(test);
124    }
125
126    private void SerializeTests(object value)
127    {
128      BenchmarkSerializeMethod(SerializeMethod.DataContractSerializer, value);
129      BenchmarkSerializeMethod(SerializeMethod.BinaryFormatter, value);
130      BenchmarkSerializeMethod(SerializeMethod.JavaScriptSerializer, value);
131      BenchmarkSerializeMethod(SerializeMethod.DataContractJsonSerializer, value);
132      BenchmarkSerializeMethod(SerializeMethod.JsonNet, value);
133      BenchmarkSerializeMethod(SerializeMethod.JsonNetWithIsoConverter, value);
134      BenchmarkSerializeMethod(SerializeMethod.JsonNetBinary, value);
135    }
136
137    [Test]
138    public void Deserialize()
139    {
140      BenchmarkDeserializeMethod<TestClass>(SerializeMethod.DataContractSerializer, XmlText);
141      BenchmarkDeserializeMethod<TestClass>(SerializeMethod.BinaryFormatter, MiscellaneousUtils.HexToBytes(BinaryFormatterHex));
142      DeserializeTests<TestClass>(JsonText);
143      BenchmarkDeserializeMethod<TestClass>(SerializeMethod.JsonNetWithIsoConverter, JsonIsoText);
144      BenchmarkDeserializeMethod<TestClass>(SerializeMethod.JsonNetBinary, MiscellaneousUtils.HexToBytes(BsonHex));
145    }
146
147    public void DeserializeTests<T>(string json)
148    {
149      BenchmarkDeserializeMethod<T>(SerializeMethod.JavaScriptSerializer, json);
150      BenchmarkDeserializeMethod<T>(SerializeMethod.DataContractJsonSerializer, json);
151      BenchmarkDeserializeMethod<T>(SerializeMethod.JsonNet, json);
152    }
153
154    [Test]
155    public void SerializeSizeNormal()
156    {
157      SerializeSize(CreateSerializationObject());
158    }
159
160    [Test]
161    public void SerializeSizeData()
162    {
163      Image image = new Image();
164      image.Data = System.IO.File.ReadAllBytes(@"bunny_pancake.jpg");
165      image.FileName = "bunny_pancake.jpg";
166      image.Author = "Hironori Akutagawa";
167      image.Caption = "I have no idea what you are talking about so here's a bunny with a pancake on its head";
168
169      SerializeSize(image);
170    }
171
172    private T TimeOperation<T>(Func<T> operation, string name)
173    {
174      // warm up
175      operation();
176
177      Stopwatch timed = new Stopwatch();
178      timed.Start();
179
180      T result = operation();
181
182      Console.WriteLine(name);
183      Console.WriteLine("{0} ms", timed.ElapsedMilliseconds);
184
185      timed.Stop();
186
187      return result;
188    }
189
190    [Test]
191    public void BuildJObject()
192    {
193      JObject o = new JObject();
194      for (int i = 0; i < 50; i++)
195      {
196        o[i.ToString()] = i;
197      }
198      string jsonText = o.ToString();
199
200      // this is extremely slow with 5000 interations
201      int interations = 1000;
202
203      TimeOperation(() =>
204        {
205          JObject oo = null;
206          for (int i = 0; i < interations; i++)
207          {
208            oo = JObject.Parse(jsonText);
209          }
210
211          return oo;
212        }, "JObject");
213    }
214
215    [Test]
216    public void BuildJObjectComparedToXml()
217    {
218      const long totalIterations = 100000;
219
220      const String xml =
221        @"<?xml  version=""1.0"" encoding=""ISO-8859-1""?>
222                <root>
223                    <property name=""Property1"">1</property>
224                    <property name=""Property2"">2</property>
225                    <property name=""Property3"">3</property>
226                    <property name=""Property4"">4</property>
227                    <property name=""Property5"">5</property>
228                </root>";
229
230      const String json =
231        @"{
232                    ""Property1"":""1"",
233                    ""Property2"":""2"",
234                    ""Property3"":""3"",
235                    ""Property4"":""4"",
236                    ""Property5"":""5""
237                }";
238
239
240      var watch = new Stopwatch();
241      watch.Start();
242      for (long iteration = 0; iteration < totalIterations; ++iteration)
243      {
244        var obj = JObject.Parse(json);
245        obj["Property1"].Value<Int32>();
246        obj["Property2"].Value<Int32>();
247        obj["Property3"].Value<Int32>();
248        obj["Property4"].Value<Int32>();
249        obj["Property5"].Value<Int32>();
250      }
251      watch.Stop();
252      var performance1 = (totalIterations/watch.ElapsedMilliseconds)*1000;
253      Console.WriteLine("JSON: " + watch.Elapsed.TotalSeconds);
254
255      watch.Reset();
256      watch.Start();
257      for (long iteration = 0; iteration < totalIterations; ++iteration)
258      {
259        var doc = XDocument.Parse(xml);
260        var alarmProperties = doc.Descendants("property");
261        foreach (var property in alarmProperties)
262        {
263          var attr = property.Attribute("name");
264          var name = attr.Value;
265          switch (name)
266          {
267            case "Property1":
268              Int32.Parse(property.Value);
269              break;
270            case "Property2":
271              Int32.Parse(property.Value);
272              break;
273            case "Property3":
274              Int32.Parse(property.Value);
275              break;
276            case "Property4":
277              Int32.Parse(property.Value);
278              break;
279            case "Property5":
280              Int32.Parse(property.Value);
281              break;
282          }
283        }
284      }
285      watch.Stop();
286      var performance2 = (totalIterations/watch.ElapsedMilliseconds)*1000;
287      Console.WriteLine("XML: " + watch.Elapsed.TotalSeconds);
288    }
289
290    private void SerializeSize(object value)
291    {
292      // this is extremely slow with 5000 interations
293      int interations = 100;
294
295      byte[] jsonBytes = TimeOperation(() =>
296        {
297          string json = null;
298          for (int i = 0; i < interations; i++)
299          {
300            json = JsonConvert.SerializeObject(value, Formatting.None);
301          }
302
303          return Encoding.UTF8.GetBytes(json);
304        }, "Json.NET");
305
306      byte[] bsonBytes = TimeOperation(() =>
307        {
308          MemoryStream ms = null;
309          for (int i = 0; i < interations; i++)
310          {
311            ms = new MemoryStream();
312            JsonSerializer serializer = new JsonSerializer();
313            BsonWriter writer = new BsonWriter(ms);
314
315            serializer.Serialize(writer, value);
316            writer.Flush();
317          }
318
319          return ms.ToArray();
320        }, "Json.NET BSON");
321
322      byte[] xmlBytes = TimeOperation(() =>
323        {
324          MemoryStream ms = null;
325          for (int i = 0; i < interations; i++)
326          {
327            ms = new MemoryStream();
328            DataContractSerializer dataContractSerializer = new DataContractSerializer(value.GetType());
329            dataContractSerializer.WriteObject(ms, value);
330          }
331
332          return ms.ToArray();
333        }, "DataContractSerializer");
334
335      byte[] wcfJsonBytes = TimeOperation(() =>
336        {
337          MemoryStream ms = null;
338          for (int i = 0; i < interations; i++)
339          {
340            ms = new MemoryStream();
341            DataContractJsonSerializer dataContractJsonSerializer = new DataContractJsonSerializer(value.GetType());
342            dataContractJsonSerializer.WriteObject(ms, value);
343          }
344
345          return ms.ToArray();
346        }, "DataContractJsonSerializer");
347
348      byte[] binaryFormatterBytes = TimeOperation(() =>
349        {
350          MemoryStream ms = null;
351          for (int i = 0; i < interations; i++)
352          {
353            ms = new MemoryStream();
354            BinaryFormatter formatter = new BinaryFormatter();
355            formatter.Serialize(ms, value);
356          }
357
358          return ms.ToArray();
359        }, "BinaryFormatter");
360
361      Console.WriteLine("Json.NET size: {0} bytes", jsonBytes.Length);
362      Console.WriteLine("BSON size: {0} bytes", bsonBytes.Length);
363      Console.WriteLine("WCF JSON size: {0} bytes", wcfJsonBytes.Length);
364      Console.WriteLine("WCF XML size: {0} bytes", xmlBytes.Length);
365      Console.WriteLine("BinaryFormatter size: {0} bytes", binaryFormatterBytes.Length);
366    }
367
368#region Serialize
369
370    private static readonly byte[] Buffer = new byte[4096];
371
372    public void BenchmarkSerializeMethod(SerializeMethod method, object value)
373    {
374      Serialize(method, value);
375
376      Stopwatch timed = new Stopwatch();
377      timed.Start();
378
379      string json = null;
380      for (int x = 0; x < Iterations; x++)
381      {
382        json = Serialize(method, value);
383      }
384
385      timed.Stop();
386
387      Console.WriteLine("Serialize method: {0}", method);
388      Console.WriteLine("{0} ms", timed.ElapsedMilliseconds);
389      Console.WriteLine(json);
390      Console.WriteLine();
391    }
392
393    private TestClass CreateSerializationObject()
394    {
395      TestClass test = new TestClass();
396
397      test.dictionary = new Dictionary<string, int> {{"Val & asd1", 1}, {"Val2 & asd1", 3}, {"Val3 & asd1", 4}};
398
399
400      test.Address1.Street = "fff Street";
401      test.Address1.Entered = DateTime.Now.AddDays(20);
402
403      test.BigNumber = 34123123123.121M;
404      test.Now = DateTime.Now.AddHours(1);
405      test.strings = new List<string>() {null, "Markus egger ]><[, (2nd)", null};
406
407      Address address = new Address();
408      address.Entered = DateTime.Now.AddDays(-1);
409      address.Street = "\u001farray\u003caddress";
410
411      test.Addresses.Add(address);
412
413      address = new Address();
414      address.Entered = DateTime.Now.AddDays(-2);
415      address.Street = "array 2 address";
416      test.Addresses.Add(address);
417      return test;
418    }
419
420    private static SimpleObject CreateSimpleObject()
421    {
422      return new SimpleObject
423      {
424        Name = "Simple-1",
425        Id = 2311,
426        Address = "Planet Earth",
427        Scores = new [] { 82, 96, 49, 40, 38, 38, 78, 96, 2, 39 }
428      };
429    }
430
431    public string SerializeJsonNet(object value)
432    {
433      Type type = value.GetType();
434
435      Newtonsoft.Json.JsonSerializer json = new Newtonsoft.Json.JsonSerializer();
436
437      json.NullValueHandling = NullValueHandling.Ignore;
438
439      json.ObjectCreationHandling = Newtonsoft.Json.ObjectCreationHandling.Replace;
440      json.MissingMemberHandling = Newtonsoft.Json.MissingMemberHandling.Ignore;
441      json.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
442
443
444      StringWriter sw = new StringWriter();
445      Newtonsoft.Json.JsonTextWriter writer = new JsonTextWriter(sw);
446
447      writer.Formatting = Formatting.None;
448
449      writer.QuoteChar = '"';
450      json.Serialize(writer, value);
451
452      string output = sw.ToString();
453      writer.Close();
454
455      return output;
456    }
457
458    public string SerializeWebExtensions(object value)
459    {
460      JavaScriptSerializer ser = new JavaScriptSerializer();
461
462      return ser.Serialize(value);
463    }
464
465    public string SerializeDataContractJson(object value)
466    {
467      DataContractJsonSerializer dataContractSerializer
468        = new DataContractJsonSerializer(value.GetType());
469
470      MemoryStream ms = new MemoryStream();
471      dataContractSerializer.WriteObject(ms, value);
472
473      ms.Seek(0, SeekOrigin.Begin);
474
475      using (StreamReader sr = new StreamReader(ms))
476      {
477        return sr.ReadToEnd();
478      }
479    }
480
481    public string SerializeDataContract(object value)
482    {
483      DataContractSerializer dataContractSerializer
484        = new DataContractSerializer(value.GetType());
485
486      MemoryStream ms = new MemoryStream();
487      dataContractSerializer.WriteObject(ms, value);
488
489      ms.Seek(0, SeekOrigin.Begin);
490
491      using (StreamReader sr = new StreamReader(ms))
492      {
493        return sr.ReadToEnd();
494      }
495    }
496
497    private string Serialize(SerializeMethod method, object value)
498    {
499      string json;
500
501      switch (method)
502      {
503        case SerializeMethod.JsonNet:
504          json = JsonConvert.SerializeObject(value);
505          break;
506        case SerializeMethod.JsonNetWithIsoConverter:
507          json = JsonConvert.SerializeObject(value, new IsoDateTimeConverter());
508          break;
509        case SerializeMethod.JsonNetBinary:
510          {
511            MemoryStream ms = new MemoryStream(Buffer);
512            JsonSerializer serializer = new JsonSerializer();
513            BsonWriter writer = new BsonWriter(ms);
514            serializer.Serialize(writer, value);
515
516            //json = BitConverter.ToString(ms.ToArray(), 0, (int)ms.Position);
517            json = "Bytes = " + ms.Position;
518            break;
519          }
520        case SerializeMethod.JavaScriptSerializer:
521          json = SerializeWebExtensions(value);
522          break;
523        case SerializeMethod.DataContractJsonSerializer:
524          json = SerializeDataContractJson(value);
525          break;
526        case SerializeMethod.DataContractSerializer:
527          json = SerializeDataContract(value);
528          break;
529        case SerializeMethod.BinaryFormatter:
530          json = SerializeBinaryFormatter(value);
531          break;
532        default:
533          throw new ArgumentOutOfRangeException("method");
534      }
535
536      return json;
537    }
538
539    private string SerializeBinaryFormatter(object value)
540    {
541      string json;
542      MemoryStream ms = new MemoryStream(Buffer);
543      BinaryFormatter formatter = new BinaryFormatter();
544      formatter.Serialize(ms, value);
545
546      json = "Bytes = " + ms.Position;
547      //json = BitConverter.ToString(ms.ToArray(), 0, (int)ms.Position);
548      return json;
549    }
550
551    #endregion
552
553#region Deserialize
554
555    public void BenchmarkDeserializeMethod<T>(SerializeMethod method, object json)
556    {
557      Deserialize<T>(method, json);
558
559      Stopwatch timed = new Stopwatch();
560      timed.Start();
561
562      T value = default(T);
563      for (int x = 0; x < Iterations; x++)
564      {
565        value = Deserialize<T>(method, json);
566      }
567
568      timed.Stop();
569
570      Console.WriteLine("Deserialize method: {0}", method);
571      Console.WriteLine("{0} ms", timed.ElapsedMilliseconds);
572      Console.WriteLine(value);
573      Console.WriteLine();
574    }
575
576    public T DeserializeJsonNet<T>(string json, bool isoDateTimeConverter)
577    {
578      Type type = typeof (T);
579
580      JsonSerializer serializer = new JsonSerializer();
581      serializer.ObjectCreationHandling = Newtonsoft.Json.ObjectCreationHandling.Replace;
582      serializer.MissingMemberHandling = Newtonsoft.Json.MissingMemberHandling.Ignore;
583      serializer.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
584      if (isoDateTimeConverter)
585        serializer.Converters.Add(new IsoDateTimeConverter());
586
587      var value = (T) serializer.Deserialize(new StringReader(json), type);
588      return value;
589      //JsonTextReader reader = new JsonTextReader(new StringReader(JsonText));
590      //while (reader.Read())
591      //{
592
593      //}
594      //return default(T);
595    }
596
597    public T DeserializeJsonNetBinary<T>(byte[] bson)
598    {
599      Type type = typeof (T);
600
601      JsonSerializer serializer = new JsonSerializer();
602      serializer.ObjectCreationHandling = Newtonsoft.Json.ObjectCreationHandling.Replace;
603      serializer.MissingMemberHandling = Newtonsoft.Json.MissingMemberHandling.Ignore;
604      serializer.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
605
606      return (T) serializer.Deserialize(new BsonReader(new MemoryStream(bson)), type);
607    }
608
609    public T DeserializeWebExtensions<T>(string json)
610    {
611      JavaScriptSerializer ser = new JavaScriptSerializer();
612
613      return ser.Deserialize<T>(json);
614    }
615
616    public T DeserializeDataContractJson<T>(string json)
617    {
618      DataContractJsonSerializer dataContractSerializer
619        = new DataContractJsonSerializer(typeof (T));
620
621      MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(json));
622
623      return (T) dataContractSerializer.ReadObject(ms);
624    }
625
626    private T Deserialize<T>(SerializeMethod method, object json)
627    {
628      switch (method)
629      {
630        case SerializeMethod.JsonNet:
631          return DeserializeJsonNet<T>((string)json, false);
632        case SerializeMethod.JsonNetWithIsoConverter:
633          return DeserializeJsonNet<T>((string)json, true);
634        case SerializeMethod.JsonNetBinary:
635          return DeserializeJsonNetBinary<T>((byte[]) json);
636        case SerializeMethod.BinaryFormatter:
637          return DeserializeBinaryFormatter<T>((byte[]) json);
638        case SerializeMethod.JavaScriptSerializer:
639          return DeserializeWebExtensions<T>((string) json);
640        case SerializeMethod.DataContractSerializer:
641          return DeserializeDataContract<T>((string) json);
642        case SerializeMethod.DataContractJsonSerializer:
643          return DeserializeDataContractJson<T>((string) json);
644        default:
645          throw new ArgumentOutOfRangeException("method");
646      }
647    }
648
649    private T DeserializeDataContract<T>(string xml)
650    {
651      MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(xml));
652
653      DataContractSerializer serializer = new DataContractSerializer(typeof (T));
654      return (T) serializer.ReadObject(ms);
655    }
656
657    private T DeserializeBinaryFormatter<T>(byte[] bytes)
658    {
659      BinaryFormatter formatter = new BinaryFormatter();
660      return (T) formatter.Deserialize(new MemoryStream(bytes));
661    }
662
663    #endregion
664
665
666
667    [Test]
668    public void SerializeLargeObject()
669    {
670      LargeRecursiveTestClass rootValue = null;
671      LargeRecursiveTestClass parentValue = null;
672      for (int i = 0; i < 20; i++)
673      {
674        LargeRecursiveTestClass currentValue = new LargeRecursiveTestClass()
675          {
676            Integer = int.MaxValue,
677            Text = "The quick red fox jumped over the lazy dog."
678          };
679
680        if (rootValue == null)
681          rootValue = currentValue;
682        if (parentValue != null)
683          parentValue.Child = currentValue;
684
685        parentValue = currentValue;
686      }
687
688      BenchmarkSerializeMethod(SerializeMethod.JsonNetBinary, rootValue);
689    }
690
691    [Test]
692    public void JObjectToString()
693    {
694      JObject test = JObject.Parse(JsonText);
695      IsoDateTimeConverter isoDateTimeConverter = null; // = new IsoDateTimeConverter();
696
697      TimeOperation<object>(() =>
698        {
699          for (int i = 0; i < Iterations; i++)
700          {
701            test["dummy"] = new JValue(i);
702            Encoding.UTF8.GetBytes(test.ToString(Formatting.None));
703          }
704          return null;
705        }, "JObject.ToString");
706    }
707
708    [Test]
709    public void JObjectToString2()
710    {
711      JObject test = JObject.Parse(JsonText);
712      IsoDateTimeConverter isoDateTimeConverter = null; // = new IsoDateTimeConverter();
713      MemoryStream ms = new MemoryStream();
714
715      TimeOperation<object>(() =>
716        {
717          for (int i = 0; i < Iterations; i++)
718          {
719            test["dummy"] = new JValue(i);
720            ms.Seek(0, SeekOrigin.Begin);
721            JsonTextWriter jsonTextWriter = new JsonTextWriter(new StreamWriter(ms));
722            test.WriteTo(jsonTextWriter);
723            jsonTextWriter.Flush();
724            ms.ToArray();
725
726            //Encoding.UTF8.GetBytes(test.ToString(Formatting.None));
727          }
728          return null;
729        }, "JObject.ToString");
730    }
731
732    [Test]
733    public void NestedJToken()
734    {
735      Stopwatch sw;
736      for (int i = 10000; i <= 100000; i += 10000)
737      {
738        sw = new Stopwatch();
739        sw.Start();
740        JArray ija = new JArray();
741        JToken ijt = ija;
742        for (int j = 0; j < i; j++)
743        {
744          JArray temp = new JArray();
745          ija.Add(temp);
746          ija = temp;
747        }
748        ija.Add(1);
749        sw.Stop();
750        Console.WriteLine("Created a JToken of depth {0} (using OM) in {1} millis", i, sw.ElapsedMilliseconds);
751      }
752    }
753
754    [Test]
755    public void DeserializeNestedJToken()
756    {
757      string json = (new string('[', 100000)) + "1" + ((new string(']', 100000)));
758
759      Stopwatch sw;
760      sw = new Stopwatch();
761      sw.Start();
762
763      var a = (JArray)JsonConvert.DeserializeObject(json);
764
765      sw.Stop();
766
767      Assert.AreEqual(1, a.Count);
768      
769      Console.WriteLine("Deserialize big ass nested array in {0} millis", sw.ElapsedMilliseconds);
770    }
771  }
772
773  public class LargeRecursiveTestClass
774  {
775    public LargeRecursiveTestClass Child { get; set; }
776    public string Text { get; set; }
777    public int Integer { get; set; }
778  }
779
780#region Classes
781
782  [Serializable]
783  [DataContract]
784  public class TestClass
785  {
786    [DataMember]
787    public string Name
788    {
789      get { return _Name; }
790      set { _Name = value; }
791    }
792
793    private string _Name = "Rick";
794
795    [DataMember]
796    public DateTime Now
797    {
798      get { return _Now; }
799      set { _Now = value; }
800    }
801
802    private DateTime _Now = DateTime.Now;
803
804    [DataMember]
805    public decimal BigNumber
806    {
807      get { return _BigNumber; }
808      set { _BigNumber = value; }
809    }
810
811    private decimal _BigNumber = 1212121.22M;
812
813    [DataMember]
814    public Address Address1
815    {
816      get { return _Address1; }
817      set { _Address1 = value; }
818    }
819
820    private Address _Address1 = new Address();
821
822
823
824    [DataMember]
825    public List<Address> Addresses
826    {
827      get { return _Addresses; }
828      set { _Addresses = value; }
829    }
830
831    private List<Address> _Addresses = new List<Address>();
832
833    [DataMember] public List<string> strings = new List<string>();
834
835    [DataMember] public Dictionary<string, int> dictionary = new Dictionary<string, int>();
836  }
837
838  [Serializable]
839  [DataContract]
840  public class Address
841  {
842    [DataMember]
843    public string Street
844    {
845      get { return _street; }
846      set { _street = value; }
847    }
848
849    private string _street = "32 Kaiea";
850
851    [DataMember]
852    public string Phone
853    {
854      get { return _Phone; }
855      set { _Phone = value; }
856    }
857
858    private string _Phone = "(503) 814-6335";
859
860    [DataMember]
861    public DateTime Entered
862    {
863      get { return _Entered; }
864      set { _Entered = value; }
865    }
866
867    private DateTime _Entered = DateTime.Parse("01/01/2007", CultureInfo.CurrentCulture.DateTimeFormat);
868  }
869
870  [DataContract]
871  [Serializable]
872  public class SimpleObject
873  {
874    [DataMember]
875    public int Id { get; set; }
876
877    [DataMember]
878    public string Name { get; set; }
879
880    [DataMember]
881    public string Address { get; set; }
882
883    [DataMember]
884    public int[] Scores { get; set; }
885  }
886
887  #endregion
888}
889
890#endif