Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
OnXmlNote.cs
1using System.Text;
2using System.Threading.Tasks;
3using System.Xml;
10
12{
16 public class OnXmlNote : OnNote
17 {
18 private ScriptableStringAttribute localName;
19 private ScriptableStringAttribute @namespace;
20
24 public OnXmlNote()
25 : base()
26 {
27 }
28
32 [DefaultValueNull]
33 public string LocalNameDefinition
34 {
35 get => this.localName?.Definition;
36 set => this.localName = new ScriptableStringAttribute(value, this);
37 }
38
42 [DefaultValueNull]
43 public string NamespaceDefinition
44 {
45 get => this.@namespace?.Definition;
46 set => this.@namespace = new ScriptableStringAttribute(value, this);
47 }
48
52 public override string LocalName => nameof(OnXmlNote);
53
58 public override IStateMachineNode Create()
59 {
60 return new OnXmlNote();
61 }
62
67 public override Task Parse(XmlElement Xml)
68 {
69 this.localName = new ScriptableStringAttribute(XML.Attribute(Xml, "localName"), this);
70 this.@namespace = new ScriptableStringAttribute(XML.Attribute(Xml, "namespace"), this);
71
72 return base.Parse(Xml);
73 }
74
82 public override async Task<bool> Register(int EventIndex, EvaluationArguments Arguments, OnEvent Event)
83 {
84 string NoteVariable = await this.EvaluateNoteVariable(Arguments);
85 string PersonalVariable = await this.EvaluateNoteVariable(Arguments);
86 string LocalName = await this.localName.Evaluate(Arguments.Variables);
87 string Namespace = await this.@namespace.Evaluate(Arguments.Variables);
88
89 TokenNoteEventHandler Handler = new TokenNoteEventHandler(Arguments,
90 EventIndex, this, NoteVariable, PersonalVariable, string.Empty,
91 string.Empty, LocalName, Namespace);
92
93 await Database.Insert(Handler);
94 await Handler.AddToCache();
95
96 return false;
97 }
98
102 public override string Label
103 {
104 get
105 {
106 StringBuilder sb = new StringBuilder();
107
108 sb.Append(nameof(OnXmlNote));
109 sb.Append('(');
110 sb.Append(this.localName.Definition);
111 sb.Append(')');
112
113 return sb.ToString();
114 }
115 }
116
117 }
118}
Helps with common XML-related tasks.
Definition: XML.cs:19
static string Attribute(XmlElement E, string Name)
Gets the value of an XML attribute.
Definition: XML.cs:914
Static interface for database persistence. In order to work, a database provider has to be assigned t...
Definition: Database.cs:19
static async Task Insert(object Object)
Inserts an object into the default collection of the database.
Definition: Database.cs:95
async Task AddToCache()
Removes the event handler from the cache.
async Task< T > Evaluate(Variables Variables)
Evaluates the attribute
Contains information required for evaluating script in a state-machine.
Abstract base class for note events.
Definition: OnNote.cs:13
Task< string > EvaluateNoteVariable(EvaluationArguments Arguments)
Evaluates the note variable definition.
Definition: OnNote.cs:62
Event raised when an XML note has been logged on the token corresponding to the state-machine.
Definition: OnXmlNote.cs:17
override async Task< bool > Register(int EventIndex, EvaluationArguments Arguments, OnEvent Event)
Registers the event
Definition: OnXmlNote.cs:82
override Task Parse(XmlElement Xml)
Parses the State-machine node.
Definition: OnXmlNote.cs:67
OnXmlNote()
Event raised when an XML note has been logged on the token corresponding to the state-machine.
Definition: OnXmlNote.cs:24
override IStateMachineNode Create()
Creates a new node of the corresponding type.
Definition: OnXmlNote.cs:58
Action executed when entering a state.
Definition: OnEvent.cs:17