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
84 public override async Task<EventHandlerReference> Register(int EventIndex, EvaluationArguments Arguments, OnEvent Event)
85 {
86 string LocalName = await this.localName.Evaluate(Arguments.Variables);
87 string Namespace = await this.@namespace.Evaluate(Arguments.Variables);
88 string SourceVariable = await this.GetSourceVariable(Arguments);
89 string Privilege = await this.GetPrivilege(Arguments);
90 string NoteVariable = await this.EvaluateNoteVariable(Arguments);
91 string PersonalVariable = await this.EvaluateNoteVariable(Arguments);
92
93 TokenNoteEventHandler Handler = new TokenNoteEventHandler(Arguments,
94 EventIndex, this, NoteVariable, PersonalVariable, SourceVariable,
95 Privilege, LocalName, Namespace);
96
97 await Database.Insert(Handler);
98 await Handler.AddToCache();
99
100 return null;
101 }
102
106 public override string Label
107 {
108 get
109 {
110 StringBuilder sb = new StringBuilder();
111
112 sb.Append(nameof(OnExternalXmlNote));
113 sb.Append('(');
114 sb.Append(this.localName.Definition);
115 sb.Append(')');
116
117 return sb.ToString();
118 }
119 }
120 }
121}
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 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< EventHandlerReference > 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
Action executed when entering a state.
Definition: OnEvent.cs:19