diff Implab/Xml/JsonXmlReader.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 7c7e9ad6fe4a
children 74e048cbaac8
line wrap: on
line diff
--- a/Implab/Xml/JsonXmlReader.cs	Mon Apr 16 02:12:57 2018 +0300
+++ b/Implab/Xml/JsonXmlReader.cs	Mon Apr 16 18:43:49 2018 +0300
@@ -2,6 +2,7 @@
 using System;
 using System.Collections.Generic;
 using System.Globalization;
+using System.IO;
 using System.Linq;
 using System.Xml;
 
@@ -588,6 +589,12 @@
             return !skip;
         }
 
+        protected override void Dispose(bool disposing) {
+            if (disposing)
+                Safe.Dispose(m_parser);
+            base.Dispose(true);
+        }
+
         public override string ToString() {
             switch (NodeType) {
                 case XmlNodeType.Element:
@@ -606,5 +613,24 @@
                     return $".{NodeType} {Name} {Value}";
             }
         }
+
+        #region static methods
+
+        public static JsonXmlReader CreateJsonXmlReader(TextReader textReader, JsonXmlReaderOptions options = null) {
+            var jsonReader = JsonReader.Create(textReader);
+            return new JsonXmlReader(jsonReader, options);
+        }
+
+        public static JsonXmlReader CreateJsonXmlReader(Stream stream, JsonXmlReaderOptions options = null) {
+            var jsonReader = JsonReader.Create(stream);
+            return new JsonXmlReader(jsonReader, options);
+        }
+
+        public static JsonXmlReader CreateJsonXmlReader(string file, JsonXmlReaderOptions options = null) {
+            var jsonReader = JsonReader.Create(file);
+            return new JsonXmlReader(jsonReader, options);
+        }
+
+        #endregion
     }
 }