Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
UserDefinedPart.cs
1using System;
2using System.Collections.Generic;
3using System.Text;
4
6{
11 {
12 private readonly string identifier;
13
19 {
20 this.identifier = Identifier;
21 }
22
26 public string Identifier => this.identifier;
27
35 public override Asn1Node Parse(Asn1Document Document, Asn1Macro Macro)
36 {
37 if (Macro.Document.namedNodes.TryGetValue(this.identifier, out Asn1Node Node))
38 {
39 if (Node is Asn1TypeDefinition TypeDef)
40 return TypeDef.Definition.Parse(Document, Macro);
41 else if (Node is Asn1Type Type)
42 return Type.Parse(Document, Macro);
43 else if (Node is Asn1FieldDefinition FieldDef)
44 return FieldDef.Type.Parse(Document, Macro);
45 else
46 throw Document.SyntaxError("Type reference expected: " + this.identifier);
47 }
48
49 if (Macro.supportingSyntax.TryGetValue(this.identifier, out SupportingSyntax Syntax))
50 return Syntax.Parse(Document, Macro);
51
52 switch (this.identifier.ToLower())
53 {
54 case "empty":return null;
55 case "type":return Document.ParseType(this.Identifier, false);
56 case "value": return Document.ParseValue();
57 default: throw Document.SyntaxError("Supporting syntax for " + this.identifier + " not found.");
58 }
59 }
60
62 public override string ToString()
63 {
64 return this.identifier;
65 }
66 }
67}
Represents an ASN.1 document.
Definition: Asn1Document.cs:21
Represents an ASN.1 field definition.
Base class for all ASN.1 nodes.
Definition: Asn1Node.cs:38
Represents an ASN.1 Type definition.
Abstract base class for ASN.1 types.
Definition: Asn1Type.cs:13
Asn1Document Document
ASN.1 document defining macro.
Definition: Asn1Macro.cs:66
Abstract base class for user-defined parts in macros
override Asn1Node Parse(Asn1Document Document, Asn1Macro Macro)
Parses the portion of the document at the current position, according to the instructions available i...
UserDefinedPart(string Identifier)
Un-typed user-defined part.