comparison Implab/Xml/XmlToJson.cs @ 264:3a6e18c432be v3

Added XmlToJson xsl transformation. Added JsonXmlReader.CreateJsonXmlReader(...) methods Added SerializationHelpers.SerializeJson/DeserializeJson methods
author cin
date Mon, 16 Apr 2018 18:43:49 +0300
parents
children
comparison
equal deleted inserted replaced
263:711572866e0c 264:3a6e18c432be
1 using System;
2 using System.IO;
3 using System.Reflection;
4 using System.Xml;
5 using System.Xml.Xsl;
6 using Implab.Components;
7 using Implab.Formats.Json;
8
9 namespace Implab.Xml {
10 public class XmlToJson {
11 const string XmlToJsonTransformId = "Implab.Xml.json.xsl";
12
13 static LazyAndWeak<XslCompiledTransform> m_default = new LazyAndWeak<XslCompiledTransform>(CreateTransform, true);
14
15 public static XslCompiledTransform Default {
16 get { return m_default.Value; }
17 }
18
19 protected static XslCompiledTransform CreateTransform() {
20 var transform = new XslCompiledTransform();
21 using(var reader = XmlReader.Create(GetDefaultTransform())) {
22 transform.Load(reader);
23 }
24 return transform;
25 }
26
27 protected static Stream GetDefaultTransform() {
28 return Assembly.GetExecutingAssembly().GetManifestResourceStream(XmlToJsonTransformId);
29 }
30
31
32 }
33 }