2using System.Collections.Generic;
3using System.Threading.Tasks;
17 private readonly LinkedList<KeyValuePair<string, IElement>> collectionProperties =
new LinkedList<KeyValuePair<string, IElement>>();
18 private readonly LinkedList<KeyValuePair<string, IElement>> blockProperties =
new LinkedList<KeyValuePair<string, IElement>>();
19 private readonly LinkedList<KeyValuePair<string, IElement>> entryProperties =
new LinkedList<KeyValuePair<string, IElement>>();
20 private readonly LinkedList<IElement[]> rows =
new LinkedList<IElement[]>();
21 private readonly List<IElement> currentRow =
new List<IElement>();
22 private readonly List<string> headers =
new List<string>();
23 private readonly Dictionary<string, int> headerOrder =
new Dictionary<string, int>();
40 get => this.variables;
41 internal set => this.variables = value;
50 LinkedList<IElement> Elements =
new LinkedList<IElement>();
52 foreach (
IElement[] Row
in this.rows)
57 int Padding = this.width - Row.Length;
65 return new ObjectMatrix(this.height, this.width, Elements)
67 ColumnNames = this.headers.ToArray()
81 this.headerOrder.Clear();
84 return Task.FromResult(
true);
93 return Task.FromResult(
true);
103 this.collectionProperties.Clear();
104 this.collectionProperties.AddLast(
new KeyValuePair<string, IElement>(
"Collection",
new StringValue(CollectionName)));
106 return Task.FromResult(
true);
115 return Task.FromResult(
true);
125 this.blockProperties.Clear();
126 this.blockProperties.AddLast(
new KeyValuePair<string, IElement>(
"BlockId",
new StringValue(BlockID)));
128 return Task.FromResult(
true);
139 this.blockProperties.AddLast(
new KeyValuePair<string, IElement>(Key,
Expression.
Encapsulate(Value)));
140 return Task.FromResult(
true);
149 return Task.FromResult(
true);
162 this.entryProperties.Clear();
163 this.entryProperties.AddLast(
new KeyValuePair<string, IElement>(
"ObjectId",
new StringValue(ObjectId)));
164 this.entryProperties.AddLast(
new KeyValuePair<string, IElement>(
"TypeName",
new StringValue(TypeName)));
165 this.entryProperties.AddLast(
new KeyValuePair<string, IElement>(
"EntryType",
new ObjectValue(
EntryType)));
166 this.entryProperties.AddLast(
new KeyValuePair<string, IElement>(
"Timestamp",
new ObjectValue(EntryTimestamp)));
168 return Task.FromResult(
true);
179 this.entryProperties.AddLast(
new KeyValuePair<string, IElement>(PropertyName,
Expression.
Encapsulate(PropertyValue)));
180 return Task.FromResult(
true);
189 if (this.variables is
null)
190 return Task.FromResult(
false);
192 this.currentRow.Clear();
194 foreach (KeyValuePair<string, IElement> P
in this.collectionProperties)
195 this.AddPropertyToRow(P.Key, P.Value);
197 foreach (KeyValuePair<string, IElement> P
in this.blockProperties)
198 this.AddPropertyToRow(P.Key, P.Value);
200 foreach (KeyValuePair<string, IElement> P
in this.entryProperties)
201 this.AddPropertyToRow(P.Key, P.Value);
203 this.rows.AddLast(this.currentRow.ToArray());
206 int c = this.currentRow.Count;
210 return Task.FromResult(
true);
213 private void AddPropertyToRow(
string Name,
IElement Value)
215 if (!this.headerOrder.TryGetValue(Name, out
int i))
217 i = this.headers.Count;
218 this.headerOrder[Name] = i;
219 this.headers.Add(Name);
222 int c = this.currentRow.Count;
228 this.currentRow.Add(
null);
232 this.currentRow.Add(Value);
235 this.currentRow[i] = Value;
245 return Task.FromResult(
true);
255 return Task.FromResult(
true);
265 return Task.FromResult(
true);
Class managing a script expression.
static IElement Encapsulate(object Value)
Encapsulates an object.
static readonly ObjectValue Null
Null value.
Export is serialized into table form, with an undefined number of columns.
Task< bool > ReportProperty(string PropertyName, object PropertyValue)
Is called when a property is reported.
Task< bool > ReportException(Exception Exception)
Is called when an exception has occurred.
Task< bool > CollectionCleared(DateTimeOffset EntryTimestamp)
Is called when the collection has been cleared.
Task< bool > EndEntry()
Is called when an entry is finished.
Task< bool > StartLedger()
Is called when export of ledger is started.
Task< bool > EndBlock()
Is called when a block in a collection is finished.
Task< bool > StartEntry(string ObjectId, string TypeName, EntryType EntryType, DateTimeOffset EntryTimestamp)
Is called when an entry is started.
ExportToVariableTable()
Export is serialized into table form, with an undefined number of columns.
Task< bool > EndLedger()
Is called when export of ledger is finished.
Task< bool > ReportError(string Message)
Is called when an error is reported.
Task< bool > EndCollection()
Is called when a collection is finished.
Task< bool > BlockMetaData(string Key, object Value)
Reports block meta-data.
Task< bool > StartBlock(string BlockID)
Is called when a block in a collection is started.
ObjectMatrix ToMatrix()
Converts the exported information into an object matrix with column headers.
Task< bool > StartCollection(string CollectionName)
Is called when a collection is started.
Interface for ledger exports.
Basic interface for all types of elements.
EntryType
Ledger entry type.