@@ -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,6 +38,7 namespace Implab.JSON { | |||
|
37 | 38 | readonly bool m_flattenArrays; |
|
38 | 39 | readonly string m_arrayItemName; |
|
39 | 40 | readonly XmlNameTable m_nameTable; |
|
41 | readonly bool m_disposeParser; | |
|
40 | 42 | |
|
41 | 43 | public JSONXmlReader(JSONParser parser, JSONXmlReaderOptions options) { |
|
42 | 44 | Safe.ArgumentNotNull(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 | |
@@ -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) { |
@@ -295,6 +306,7 namespace Implab.JSON { | |||
|
295 | 306 | |
|
296 | 307 | protected override void Dispose(bool disposing) { |
|
297 | 308 | if (disposing) { |
|
309 | if (m_disposeParser) | |
|
298 | 310 | m_parser.Dispose(); |
|
299 | 311 | } |
|
300 | 312 | base.Dispose(disposing); |
General Comments 0
You need to be logged in to leave comments.
Login now