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
84 public override async Task<EventHandlerReference> Register(int EventIndex, EvaluationArguments Arguments, OnEvent Event)
85 {
86 string NoteVariable = await this.EvaluateNoteVariable(Arguments);
87 string PersonalVariable = await this.EvaluateNoteVariable(Arguments);
88 string LocalName = await this.localName.Evaluate(Arguments.Variables);
89 string Namespace = await this.@namespace.Evaluate(Arguments.Variables);
90
91 TokenNoteEventHandler Handler = new TokenNoteEventHandler(Arguments,
92 EventIndex, this, NoteVariable, PersonalVariable, string.Empty,
93 string.Empty, LocalName, Namespace);
94
95 await Database.Insert(Handler);
96 await Handler.AddToCache();
97
98 return null;
99 }
100
104 public override string Label
105 {
106 get
107 {
108 StringBuilder sb = new StringBuilder();
109
110 sb.Append(nameof(OnXmlNote));
111 sb.Append('(');
112 sb.Append(this.localName.Definition);
113 sb.Append(')');
114
115 return sb.ToString();
116 }
117 }
118
119 }
120}
Helps with common XML-related tasks.
Definition: XML.cs:21
static string Attribute(XmlElement E, string Name)
Gets the value of an XML attribute.
Definition: XML.cs:1062
Static interface for database persistence. In order to work, a database provider has to be assigned t...
Definition: Database.cs:21
static async Task Insert(object Object)
Inserts an object into the default collection of the database.
Definition: Database.cs:97
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< EventHandlerReference > Register(int EventIndex, EvaluationArguments Arguments, OnEvent Event)
Registers the event
Definition: OnXmlNote.cs:84
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:19