Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
UserDefinedOptions.cs
1using System;
2using System.Collections.Generic;
3using System.Text;
4
6{
11 {
12 private readonly UserDefinedItem[] options;
13
19 {
20 this.options = Options;
21 }
22
26 public UserDefinedItem[] Options => this.options;
27
35 public override Asn1Node Parse(Asn1Document Document, Asn1Macro Macro)
36 {
37 int Bak = Document.pos;
38 int BestPos = -1;
39 Asn1Node Best = null;
40 Asn1Node Option;
41
42 foreach (UserDefinedItem Item in this.options)
43 {
44 Document.pos = Bak;
45
46 try
47 {
48 Option = Item.Parse(Document, Macro);
49 if (Best is null || Document.pos > BestPos)
50 {
51 BestPos = Document.pos;
52 Best = Option;
53 }
54 }
55 catch (Exception)
56 {
57 // Ignore
58 }
59 }
60
61 if (BestPos < 0)
62 throw Document.SyntaxError("Invalid option.");
63
64 Document.pos = BestPos;
65
66 return Best;
67 }
68 }
69}
Represents an ASN.1 document.
Definition: Asn1Document.cs:21
Base class for all ASN.1 nodes.
Definition: Asn1Node.cs:38
Abstract base class for user-defined parts in macros
abstract Asn1Node Parse(Asn1Document Document, Asn1Macro Macro)
Parses the portion of the document at the current position, according to the instructions available i...
override Asn1Node Parse(Asn1Document Document, Asn1Macro Macro)
Parses the portion of the document at the current position, according to the instructions available i...
UserDefinedOptions(UserDefinedItem[] Options)
Set of options