Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
EntryEventNode.cs
1using System.Text;
2using System.Threading.Tasks;
3using System.Xml;
10
12{
16 public abstract class EntryEventNode : EventNode
17 {
18 private ScriptableStringAttribute entryVariable;
19 private ScriptableStringAttribute collectionName;
20 private ScriptableStringAttribute typeName;
21
26 : base()
27 {
28 }
29
33 [DefaultValueNull]
35 {
36 get => this.entryVariable?.Definition;
37 set => this.entryVariable = new ScriptableStringAttribute(value, this);
38 }
39
43 [DefaultValueNull]
45 {
46 get => this.collectionName?.Definition;
47 set => this.collectionName = new ScriptableStringAttribute(value, this);
48 }
49
53 [DefaultValueNull]
54 public string TypeNameDefinition
55 {
56 get => this.typeName?.Definition;
57 set => this.typeName = new ScriptableStringAttribute(value, this);
58 }
59
64 public override Task Parse(XmlElement Xml)
65 {
66 this.entryVariable = new ScriptableStringAttribute(XML.Attribute(Xml, "sellerVariable"), this);
67 this.collectionName = new ScriptableStringAttribute(XML.Attribute(Xml, "collectionName"), this);
68 this.typeName = new ScriptableStringAttribute(XML.Attribute(Xml, "typeName"), this);
69
70 return base.Parse(Xml);
71 }
72
79 public override async Task<bool> Register(int EventIndex, EvaluationArguments Arguments, OnEvent Event)
80 {
81 string Collection = await this.collectionName.Evaluate(Arguments.Variables);
82 string Type = await this.typeName.Evaluate(Arguments.Variables);
83
84 EntryEventHandler Handler = new EntryEventHandler(Arguments, EventIndex, this, Collection, Type);
85
86 await Database.Insert(Handler);
87 await Handler.AddToCache();
88
89 return false;
90 }
91
95 public override string Label
96 {
97 get
98 {
99 StringBuilder sb = new StringBuilder();
100
101 sb.Append(this.GetType().Name);
102 sb.Append('(');
103 sb.Append(this.typeName.Definition);
104 sb.Append(')');
105
106 return sb.ToString();
107 }
108 }
109
110 }
111}
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.
Event handler for entry events.
async Task< T > Evaluate(Variables Variables)
Evaluates the attribute
Contains information required for evaluating script in a state-machine.
Abstract base class for entry event nodes.
override string Label
UML Label for event.
string CollectionNameDefinition
Collection Name definition.
EntryEventNode()
Abstract base class for entry event nodes.
override async Task< bool > Register(int EventIndex, EvaluationArguments Arguments, OnEvent Event)
Registers the event
string EntryVariableDefinition
Entry Variable definition.
string TypeNameDefinition
Type Name definition.
override Task Parse(XmlElement Xml)
Parses the State-machine node.
Abstract base class for State-Machine event nodes.
Definition: EventNode.cs:10
Action executed when entering a state.
Definition: OnEvent.cs:17