@@ -2,6 +2,7 | |||||
2 | using Implab.Parsing; |
|
2 | using Implab.Parsing; | |
3 | using System; |
|
3 | using System; | |
4 | using System.Collections.Generic; |
|
4 | using System.Collections.Generic; | |
|
5 | using System.Globalization; | |||
5 | using System.IO; |
|
6 | using System.IO; | |
6 | using System.Linq; |
|
7 | using System.Linq; | |
7 | using System.Text; |
|
8 | using System.Text; | |
@@ -37,6 +38,7 namespace Implab.JSON { | |||||
37 | readonly bool m_flattenArrays; |
|
38 | readonly bool m_flattenArrays; | |
38 | readonly string m_arrayItemName; |
|
39 | readonly string m_arrayItemName; | |
39 | readonly XmlNameTable m_nameTable; |
|
40 | readonly XmlNameTable m_nameTable; | |
|
41 | readonly bool m_disposeParser; | |||
40 |
|
42 | |||
41 | public JSONXmlReader(JSONParser parser, JSONXmlReaderOptions options) { |
|
43 | public JSONXmlReader(JSONParser parser, JSONXmlReaderOptions options) { | |
42 | Safe.ArgumentNotNull(parser, "parser"); |
|
44 | Safe.ArgumentNotNull(parser, "parser"); | |
@@ -49,6 +51,7 namespace Implab.JSON { | |||||
49 | m_flattenArrays = options.FlattenArrays; |
|
51 | m_flattenArrays = options.FlattenArrays; | |
50 | m_arrayItemName = options.ArrayItemName ?? "item"; |
|
52 | m_arrayItemName = options.ArrayItemName ?? "item"; | |
51 | m_nameTable = options.NameTable ?? new NameTable(); |
|
53 | m_nameTable = options.NameTable ?? new NameTable(); | |
|
54 | m_disposeParser = options.DisposeParser; | |||
52 | } else { |
|
55 | } else { | |
53 | m_prefix = String.Empty; |
|
56 | m_prefix = String.Empty; | |
54 | m_namespaceUri = String.Empty; |
|
57 | m_namespaceUri = String.Empty; | |
@@ -56,6 +59,7 namespace Implab.JSON { | |||||
56 | m_flattenArrays = false; |
|
59 | m_flattenArrays = false; | |
57 | m_arrayItemName = "item"; |
|
60 | m_arrayItemName = "item"; | |
58 | m_nameTable = new NameTable(); |
|
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 | public override string Value { |
|
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 | void SetLocalName(string name) { |
|
287 | void SetLocalName(string name) { | |
@@ -295,6 +306,7 namespace Implab.JSON { | |||||
295 |
|
306 | |||
296 | protected override void Dispose(bool disposing) { |
|
307 | protected override void Dispose(bool disposing) { | |
297 | if (disposing) { |
|
308 | if (disposing) { | |
|
309 | if (m_disposeParser) | |||
298 | m_parser.Dispose(); |
|
310 | m_parser.Dispose(); | |
299 | } |
|
311 | } | |
300 | base.Dispose(disposing); |
|
312 | base.Dispose(disposing); |
General Comments 0
You need to be logged in to leave comments.
Login now