14 private byte[] digest =
null;
15 private byte[] signature =
null;
16 private byte[] link =
null;
17 private string collection =
string.Empty;
18 private string creator =
string.Empty;
19 private string url =
string.Empty;
20 private ulong bytes = 0;
21 private DateTime created = DateTime.MinValue;
22 private DateTime updated = DateTime.MinValue;
23 private DateTime expires = DateTime.MaxValue;
40 set => this.digest = value;
48 get => this.signature;
49 set => this.signature = value;
58 set => this.link = value;
66 get => this.collection;
67 set => this.collection = value;
76 set => this.creator = value;
85 set => this.url = value;
94 set => this.created = value;
103 set => this.updated = value;
112 set => this.expires = value;
121 set => this.status = value;
130 set => this.bytes = value;
139 Xml.Append(
" xmlns='");
142 Xml.Append(Convert.ToBase64String(
this.digest));
144 Xml.Append(Convert.ToBase64String(
this.signature));
146 if (!(this.link is
null))
149 Xml.Append(Convert.ToBase64String(
this.link));
152 Xml.Append(
"' cn='");
154 Xml.Append(
"' cr='");
156 Xml.Append(
"' ct='");
159 if (this.updated != DateTime.MinValue)
165 if (this.expires != DateTime.MaxValue)
174 Xml.Append(this.status.ToString());
178 Xml.Append(this.url);
180 Xml.Append(this.bytes.ToString());
191 foreach (XmlAttribute Attr
in E.Attributes)
196 Event.digest = Convert.FromBase64String(Attr.Value);
200 Event.signature = Convert.FromBase64String(Attr.Value);
204 Event.link = Convert.FromBase64String(Attr.Value);
208 Event.collection = Attr.Value;
212 Event.creator = Attr.Value;
217 throw new InvalidOperationException(
"Invalid creation time.");
224 throw new InvalidOperationException(
"Invalid update time.");
231 throw new InvalidOperationException(
"Invalid expires time.");
238 throw new InvalidOperationException(
"Invalid block status.");
244 Event.url = Attr.Value;
248 if (!ulong.TryParse(Attr.Value, out ulong
Bytes))
249 throw new InvalidOperationException(
"Invalid block size.");
259 if (Attr.Prefix !=
"xmlns")
260 throw new InvalidOperationException(
"Invalid attribute: " + Attr.Name);
Helps with common XML-related tasks.
static string Encode(string s)
Encodes a string for use in XML.
static bool TryParse(string s, out DateTime Value)
Tries to decode a string encoded DateTime.
const string NeuroLedgerNamespace
http://waher.se/NL
Abstract base class for Neuro-Ledger block PEP events.
byte[] Digest
Digest of block.
byte[] Signature
Block signature
BlockStatus Status
Block status
DateTime Expires
When block expires (DateTime.MaxValue if it never expires.)
string Collection
Collection name
DateTime Created
When block was created
ulong Bytes
Size of block, in bytes.
void Parse(XmlElement E, BlockEvent Event)
Parses Block attributes from a block element.
void AddAttributes(StringBuilder Xml)
Adds XML attributes related to the block.
DateTime Updated
When block was updated (DateTime.MinValue if not updated.)
byte[] Link
If block links to another block (with changes). null, if no link.
BlockEvent()
Abstract base class for Neuro-Ledger block PEP events.
Abstract base class for Neuro-Ledger PEP events.
BlockStatus
Status of the block.