annotate Implab.Playground/Program.cs @ 229:5f7a3e1d32b9 v2

JsonXmlReader performance tuning JsonScanner now operates strings and doesn't parses number and literals. Added SerializationHelpers to common serialize/deserialize operations
author cin
date Tue, 12 Sep 2017 19:07:42 +0300
parents
children d6fe09f5592c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
229
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents:
diff changeset
1 using Implab.Formats.Json;
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents:
diff changeset
2 using Implab.Xml;
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents:
diff changeset
3 using System;
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents:
diff changeset
4 using System.Collections.Generic;
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents:
diff changeset
5 using System.IO;
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents:
diff changeset
6 using System.Linq;
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents:
diff changeset
7 using System.Text;
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents:
diff changeset
8 using System.Threading.Tasks;
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents:
diff changeset
9 using System.Xml;
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents:
diff changeset
10 using System.Xml.Serialization;
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents:
diff changeset
11
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents:
diff changeset
12 namespace Implab.Playground {
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents:
diff changeset
13 public class Program {
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents:
diff changeset
14
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents:
diff changeset
15 [XmlRoot(Namespace = "XmlSimpleData")]
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents:
diff changeset
16 public class XmlSimpleModel {
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents:
diff changeset
17 [XmlElement]
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents:
diff changeset
18 public string Name { get; set; }
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents:
diff changeset
19
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents:
diff changeset
20 [XmlElement]
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents:
diff changeset
21 public int Order { get; set; }
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents:
diff changeset
22
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents:
diff changeset
23 [XmlElement]
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents:
diff changeset
24 public string[] Items { get; set; }
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents:
diff changeset
25
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents:
diff changeset
26 }
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents:
diff changeset
27
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents:
diff changeset
28 static void Main(string[] args) {
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents:
diff changeset
29 var model = new XmlSimpleModel {
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents:
diff changeset
30 Name = "Tablet",
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents:
diff changeset
31 Order = 10,
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents:
diff changeset
32 Items = new string[] { "z1", "z2", "z3" }
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents:
diff changeset
33 };
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents:
diff changeset
34
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents:
diff changeset
35 var doc = SerializationHelpers.SerializeAsXmlDocument(model);
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents:
diff changeset
36
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents:
diff changeset
37 var m2 = SerializationHelpers.DeserializeFromXmlNode<XmlSimpleModel>(doc.DocumentElement);
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents:
diff changeset
38
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents:
diff changeset
39 Console.WriteLine("done");
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents:
diff changeset
40 }
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents:
diff changeset
41 }
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents:
diff changeset
42 }