3using System.Threading.Tasks;
19 private XmlWriter output;
20 private bool exportCollection =
false;
21 private bool inCollection =
false;
22 private bool inMetaData =
false;
34 bool OnlySelectedCollections, Array SelectedCollections)
35 : base(
FileName,
Created, File, OnlySelectedCollections, SelectedCollections)
43 if (!(this.output is
null))
47 this.output.Dispose();
58 public override async Task<bool>
Start()
60 await this.output.WriteStartDocumentAsync();
70 public override async Task<bool>
End()
72 await this.output.WriteEndElementAsync();
73 await this.output.WriteEndDocumentAsync();
87 if (!(Provider is
null))
88 await this.output.WriteAttributeStringAsync(
string.Empty,
"provider",
string.Empty, Provider.GetType().FullName);
99 await this.output.WriteEndElementAsync();
113 if (!(Provider is
null))
114 await this.output.WriteAttributeStringAsync(
string.Empty,
"provider",
string.Empty, Provider.GetType().FullName);
125 await this.output.WriteEndElementAsync();
136 this.inCollection =
true;
140 await this.output.WriteAttributeStringAsync(
string.Empty,
"name",
string.Empty, CollectionName);
152 this.inCollection =
false;
153 if (this.exportCollection)
154 await this.output.WriteEndElementAsync();
165 if (this.exportCollection)
177 if (this.exportCollection)
178 await this.output.WriteEndElementAsync();
191 if (this.exportCollection)
194 await this.output.WriteAttributeStringAsync(
string.Empty,
"name",
string.Empty, FieldName);
195 await this.output.WriteAttributeStringAsync(
string.Empty,
"ascending",
string.Empty,
CommonTypes.
Encode(Ascending));
196 await this.output.WriteEndElementAsync();
209 if (this.exportCollection)
212 await this.output.WriteAttributeStringAsync(
string.Empty,
"id",
string.Empty, BlockID);
224 if (this.exportCollection)
228 await this.output.WriteEndElementAsync();
229 this.inMetaData =
false;
232 await this.output.WriteEndElementAsync();
246 if (this.exportCollection)
248 if (!this.inMetaData)
251 this.inMetaData =
true;
265 public override async Task<string>
StartObject(
string ObjectId,
string TypeName)
267 if (this.exportCollection)
270 await this.output.WriteAttributeStringAsync(
string.Empty,
"id",
string.Empty, ObjectId);
271 await this.output.WriteAttributeStringAsync(
string.Empty,
"type",
string.Empty, TypeName);
283 if (this.exportCollection)
285 await this.output.WriteEndElementAsync();
302 if (this.exportCollection)
306 await this.output.WriteEndElementAsync();
307 this.inMetaData =
false;
311 await this.output.WriteAttributeStringAsync(
string.Empty,
"id",
string.Empty, ObjectId);
312 await this.output.WriteAttributeStringAsync(
string.Empty,
"type",
string.Empty, TypeName);
313 await this.output.WriteAttributeStringAsync(
string.Empty,
"ts",
string.Empty,
XML.
Encode(EntryTimestamp));
325 if (this.exportCollection)
327 await this.output.WriteEndElementAsync();
341 if (this.exportCollection)
345 await this.output.WriteEndElementAsync();
346 this.inMetaData =
false;
350 await this.output.WriteAttributeStringAsync(
string.Empty,
"ts",
string.Empty,
XML.
Encode(EntryTimestamp));
362 public override async Task<bool>
ReportProperty(
string PropertyName,
object PropertyValue)
364 if (this.exportCollection)
377 if (!this.inCollection || this.exportCollection)
390 if (!this.inCollection || this.exportCollection)
393 await this.output.WriteAttributeStringAsync(
string.Empty,
"message",
string.Empty, Exception.Message);
394 this.output.WriteElementString(
"StackTrace",
Log.
CleanStackTrace(Exception.StackTrace));
396 if (Exception is AggregateException AggregateException)
398 foreach (Exception ex
in AggregateException.InnerExceptions)
401 else if (!(Exception.InnerException is
null))
404 await this.output.WriteEndElementAsync();
424 await this.output.WriteEndElementAsync();
438 await this.output.WriteAttributeStringAsync(
string.Empty,
"fileName",
string.Empty,
FileName);
441 long c = File.Length;
457 await File.ReadAllAsync(Buf, 0, j);
459 this.output.WriteElementString(
"Chunk", Convert.ToBase64String(Buf, 0, j, Base64FormattingOptions.None));
463 await this.output.WriteEndElementAsync();
Helps with parsing of commong data types.
static string Encode(bool x)
Encodes a Boolean for use in XML and other formats.
Helps with common XML-related tasks.
static string Encode(string s)
Encodes a string for use in XML.
Static class managing the application event log. Applications and services log events on this static ...
static string CleanStackTrace(string StackTrace)
Cleans a Stack Trace string, removing entries from the asynchronous execution model,...
Simple ledger that records anything that happens in the database to XML files in the program data fol...
const string Namespace
http://waher.se/Schema/Export.xsd
static async Task ReportProperty(XmlWriter Output, string PropertyName, object PropertyValue, string Namespace)
Serializes a property to XML.
Interface for database providers that can be plugged into the static Database class.
Interface for ledger providers that can be plugged into the static Ledger class.
EntryType
Ledger entry type.