Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
OnExternalXmlNote.cs
1using System.Text;
2using System.Threading.Tasks;
3using System.Xml;
10
12{
17 {
18 private ScriptableStringAttribute localName;
19 private ScriptableStringAttribute @namespace;
20
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(OnExternalXmlNote);
53
58 public override IStateMachineNode Create()
59 {
60 return new OnExternalXmlNote();
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 LocalName = await this.localName.Evaluate(Arguments.Variables);
85 string Namespace = await this.@namespace.Evaluate(Arguments.Variables);
86 string SourceVariable = await this.GetSourceVariable(Arguments);
87 string Privilege = await this.GetPrivilege(Arguments);
88 string NoteVariable = await this.EvaluateNoteVariable(Arguments);
89 string PersonalVariable = await this.EvaluateNoteVariable(Arguments);
90
91 TokenNoteEventHandler Handler = new TokenNoteEventHandler(Arguments,
92 EventIndex, this, NoteVariable, PersonalVariable, SourceVariable,
93 Privilege, LocalName, Namespace);
94
95 await Database.Insert(Handler);
96 await Handler.AddToCache();
97
98 return false;
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}
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 external note events.
Task< string > GetSourceVariable(EvaluationArguments Arguments)
Evaluates the source variable to use (if any).
Task< string > GetPrivilege(EvaluationArguments Arguments)
Evaluates the privilege to require (if any).
Event raised when an external XML note has been logged on the token corresponding to the state-machin...
override async Task< bool > Register(int EventIndex, EvaluationArguments Arguments, OnEvent Event)
Registers the event
override IStateMachineNode Create()
Creates a new node of the corresponding type.
OnExternalXmlNote()
Event raised when an external XML note has been logged on the token corresponding to the state-machin...
override Task Parse(XmlElement Xml)
Parses the State-machine node.
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
Action executed when entering a state.
Definition: OnEvent.cs:17