@@ -38,10 +38,8 namespace Implab.JSON { | |||||
38 | readonly bool m_flattenArrays; |
|
38 | readonly bool m_flattenArrays; | |
39 | readonly string m_arrayItemName; |
|
39 | readonly string m_arrayItemName; | |
40 | readonly XmlNameTable m_nameTable; |
|
40 | readonly XmlNameTable m_nameTable; | |
41 | readonly bool m_disposeParser; |
|
|||
42 |
|
41 | |||
43 |
|
|
42 | JSONXmlReader(JSONParser parser, JSONXmlReaderOptions options) { | |
44 | Safe.ArgumentNotNull(parser, "parser"); |
|
|||
45 | m_parser = parser; |
|
43 | m_parser = parser; | |
46 |
|
44 | |||
47 | if (options != null) { |
|
45 | if (options != null) { | |
@@ -51,7 +49,6 namespace Implab.JSON { | |||||
51 | m_flattenArrays = options.FlattenArrays; |
|
49 | m_flattenArrays = options.FlattenArrays; | |
52 | m_arrayItemName = options.ArrayItemName ?? "item"; |
|
50 | m_arrayItemName = options.ArrayItemName ?? "item"; | |
53 | m_nameTable = options.NameTable ?? new NameTable(); |
|
51 | m_nameTable = options.NameTable ?? new NameTable(); | |
54 | m_disposeParser = options.DisposeParser; |
|
|||
55 | } else { |
|
52 | } else { | |
56 | m_prefix = String.Empty; |
|
53 | m_prefix = String.Empty; | |
57 | m_namespaceUri = String.Empty; |
|
54 | m_namespaceUri = String.Empty; | |
@@ -59,7 +56,6 namespace Implab.JSON { | |||||
59 | m_flattenArrays = false; |
|
56 | m_flattenArrays = false; | |
60 | m_arrayItemName = "item"; |
|
57 | m_arrayItemName = "item"; | |
61 | m_nameTable = new NameTable(); |
|
58 | m_nameTable = new NameTable(); | |
62 | m_disposeParser = false; |
|
|||
63 | } |
|
59 | } | |
64 | } |
|
60 | } | |
65 |
|
61 | |||
@@ -306,17 +302,23 namespace Implab.JSON { | |||||
306 |
|
302 | |||
307 | protected override void Dispose(bool disposing) { |
|
303 | protected override void Dispose(bool disposing) { | |
308 | if (disposing) { |
|
304 | if (disposing) { | |
309 |
|
|
305 | m_parser.Dispose(); | |
310 | m_parser.Dispose(); |
|
|||
311 | } |
|
306 | } | |
312 | base.Dispose(disposing); |
|
307 | base.Dispose(disposing); | |
313 | } |
|
308 | } | |
314 |
|
309 | |||
|
310 | public static JSONXmlReader Create(string file, JSONXmlReaderOptions options) { | |||
|
311 | return Create(File.OpenText(file), options); | |||
|
312 | } | |||
315 |
|
313 | |||
316 |
public static JSONXmlReader |
|
314 | public static JSONXmlReader Create(TextReader reader, JSONXmlReaderOptions options) { | |
317 | var stream = File.OpenText(file); |
|
315 | return new JSONXmlReader(new JSONParser(reader, true), options); | |
318 | var parser = new JSONParser(stream, true); |
|
316 | } | |
319 | return new JSONXmlReader(parser, options); |
|
317 | ||
|
318 | public static JSONXmlReader Create(Stream stream, JSONXmlReaderOptions options) { | |||
|
319 | Safe.ArgumentNotNull(stream, "stream"); | |||
|
320 | // HACK don't dispose StreaReader to keep stream opened | |||
|
321 | return Create(new StreamReader(stream), options); | |||
320 | } |
|
322 | } | |
321 | } |
|
323 | } | |
322 | } |
|
324 | } |
General Comments 0
You need to be logged in to leave comments.
Login now