HamBook – Diff between revs 3 and 54
?pathlinks?
Rev 3 | Rev 54 | |||
---|---|---|---|---|
Line 1... | Line -... | |||
1 | using HamBook.Utilities; |
- | ||
2 | using System; |
1 | using System; |
|
3 | using System.Collections.Generic; |
2 | using System.Collections.Generic; |
|
4 | using System.IO; |
3 | using System.IO; |
|
5 | using System.Text; |
4 | using System.Text; |
|
6 | using System.Threading; |
5 | using System.Threading; |
|
7 | using System.Threading.Tasks; |
6 | using System.Threading.Tasks; |
|
Line 14... | Line 13... | |||
14 | public static class Serialization |
13 | public static class Serialization |
|
15 | { |
14 | { |
|
16 | #region Public Methods |
15 | #region Public Methods |
|
Line 17... | Line 16... | |||
17 | |
16 | |
|
18 | public static async Task<SerializationState> Deserialize<T>(string file, string targetNamespace, |
17 | public static async Task<SerializationState> Deserialize<T>(string file, string targetNamespace, |
|
19 | string schemeUri, |
18 | string schemeUri, |
|
20 | CancellationToken cancellationToken) |
19 | CancellationToken cancellationToken) |
|
21 | { |
20 | { |
|
Line 22... | Line 21... | |||
22 | var xmlSerializer = new XmlSerializer(typeof(T)); |
21 | var xmlSerializer = new XmlSerializer(typeof(T)); |
|
Line 59... | Line 58... | |||
59 | var stringBuilder = new StringBuilder(); |
58 | var stringBuilder = new StringBuilder(); |
|
Line 60... | Line 59... | |||
60 | |
59 | |
|
61 | using (var stringWriter = new StringWriter(stringBuilder)) |
60 | using (var stringWriter = new StringWriter(stringBuilder)) |
|
62 | { |
61 | { |
|
63 | while (await xmlReader.ReadAsync()) |
- | ||
64 | { |
62 | while (await xmlReader.ReadAsync()) |
|
65 | await stringWriter.WriteAsync(await xmlReader.ReadOuterXmlAsync()); |
- | ||
66 | } |
63 | await stringWriter.WriteAsync(await xmlReader.ReadOuterXmlAsync()); |
|
Line 67... | Line 64... | |||
67 | } |
64 | } |
|
68 | |
65 | |
|
69 | using (var stringReader = new StringReader(stringBuilder.ToString())) |
66 | using (var stringReader = new StringReader(stringBuilder.ToString())) |
|
Line 87... | Line 84... | |||
87 | |
84 | |
|
88 | return new SerializationSuccess<T>(servers, validationEventArgs); |
85 | return new SerializationSuccess<T>(servers, validationEventArgs); |
|
Line 89... | Line 86... | |||
89 | } |
86 | } |
|
90 | |
87 | |
|
91 | public static async Task<SerializationState> Serialize<T>(T @object, string file, string name, string subset, |
88 | public static async Task<SerializationState> Serialize<T>(T @object, string file, string name, string subset, |
|
92 | CancellationToken cancellationToken) |
89 | CancellationToken cancellationToken) |
|
Line 93... | Line 90... | |||
93 | { |
90 | { |
|
94 | var xmlSerializer = new XmlSerializer(typeof(T)); |
91 | var xmlSerializer = new XmlSerializer(typeof(T)); |