##// END OF EJS Templates
fixed: JSONXmlReader.Value returns invalid textual representation for numbers.
cin -
r63:908b4f340c69 default
parent child
Show More
@@ -2,6 +2,7
2 2 using Implab.Parsing;
3 3 using System;
4 4 using System.Collections.Generic;
5 using System.Globalization;
5 6 using System.IO;
6 7 using System.Linq;
7 8 using System.Text;
@@ -37,7 +38,8 namespace Implab.JSON {
37 38 readonly bool m_flattenArrays;
38 39 readonly string m_arrayItemName;
39 40 readonly XmlNameTable m_nameTable;
40
41 readonly bool m_disposeParser;
42
41 43 public JSONXmlReader(JSONParser parser, JSONXmlReaderOptions options) {
42 44 Safe.ArgumentNotNull(parser, "parser");
43 45 m_parser = parser;
@@ -49,6 +51,7 namespace Implab.JSON {
49 51 m_flattenArrays = options.FlattenArrays;
50 52 m_arrayItemName = options.ArrayItemName ?? "item";
51 53 m_nameTable = options.NameTable ?? new NameTable();
54 m_disposeParser = options.DisposeParser;
52 55 } else {
53 56 m_prefix = String.Empty;
54 57 m_namespaceUri = String.Empty;
@@ -56,6 +59,7 namespace Implab.JSON {
56 59 m_flattenArrays = false;
57 60 m_arrayItemName = "item";
58 61 m_nameTable = new NameTable();
62 m_disposeParser = false;
59 63 }
60 64 }
61 65
@@ -72,7 +76,7 namespace Implab.JSON {
72 76
73 77 public override int Depth {
74 78 get {
75 return m_localNameStack.Count+m_depthCorrection;
79 return m_localNameStack.Count + m_depthCorrection;
76 80 }
77 81 }
78 82
@@ -270,7 +274,14 namespace Implab.JSON {
270 274 }
271 275
272 276 public override string Value {
273 get { return m_parser.ElementValue == null ? String.Empty : m_parser.ElementValue.ToString(); }
277 get {
278 if (m_parser.ElementValue == null)
279 return String.Empty;
280 if (Convert.GetTypeCode(m_parser.ElementValue) == TypeCode.Double)
281 return ((double)m_parser.ElementValue).ToString(CultureInfo.InvariantCulture);
282 else
283 return (string)m_parser.ElementValue;
284 }
274 285 }
275 286
276 287 void SetLocalName(string name) {
@@ -290,12 +301,13 namespace Implab.JSON {
290 301 }
291 302
292 303 public override void Close() {
293
304
294 305 }
295 306
296 307 protected override void Dispose(bool disposing) {
297 308 if (disposing) {
298 m_parser.Dispose();
309 if (m_disposeParser)
310 m_parser.Dispose();
299 311 }
300 312 base.Dispose(disposing);
301 313 }
@@ -57,5 +57,13 namespace Implab.JSON {
57 57 get;
58 58 set;
59 59 }
60
61 /// <summary>
62 /// Флаг, означающий, что неужно освободить парсер по окончанию работы.
63 /// </summary>
64 public bool DisposeParser {
65 get;
66 set;
67 }
60 68 }
61 69 }
General Comments 0
You need to be logged in to leave comments. Login now