Mercurial > pub > ImplabNet
view Implab/Xml/XmlToJson.cs @ 280:f07be402ab02 v3
Added Trace<T>.Debug(...) method for debug messages
Added ContainerBuilde.LoadConfig(Uri) method
author | cin |
---|---|
date | Fri, 25 May 2018 19:15:26 +0300 |
parents | 3a6e18c432be |
children |
line wrap: on
line source
using System; using System.IO; using System.Reflection; using System.Xml; using System.Xml.Xsl; using Implab.Components; using Implab.Formats.Json; namespace Implab.Xml { public class XmlToJson { const string XmlToJsonTransformId = "Implab.Xml.json.xsl"; static LazyAndWeak<XslCompiledTransform> m_default = new LazyAndWeak<XslCompiledTransform>(CreateTransform, true); public static XslCompiledTransform Default { get { return m_default.Value; } } protected static XslCompiledTransform CreateTransform() { var transform = new XslCompiledTransform(); using(var reader = XmlReader.Create(GetDefaultTransform())) { transform.Load(reader); } return transform; } protected static Stream GetDefaultTransform() { return Assembly.GetExecutingAssembly().GetManifestResourceStream(XmlToJsonTransformId); } } }