Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
FinalizeScript.cs
1using System.Threading.Tasks;
2using System.Xml;
3using Waher.Script;
4
6{
12 {
13 private string script;
14 private Expression expression;
15
22 : base(Parent, Model)
23 {
24 }
25
29 public string Script => this.script;
30
34 public Expression Expression => this.expression;
35
39 public override string LocalName => nameof(FinalizeScript);
40
48 {
49 return new FinalizeScript(Parent, Model);
50 }
51
56 public override Task FromXml(XmlElement Definition)
57 {
58 this.script = Values.Script.RemoveIndent(Definition.InnerText);
59 this.expression = new Expression(this.script);
60
61 return Task.CompletedTask;
62 }
63
67 public override async Task Finalize()
68 {
69 await this.expression.EvaluateAsync(this.Model.Variables);
70 await base.Initialize();
71 }
72 }
73}
Root node of a simulation model
Definition: Model.cs:49
Variables Variables
Model variables.
Definition: Model.cs:175
Executes script at the end of the simulation, allowing for persistance and cleaning of states.
override Task FromXml(XmlElement Definition)
Sets properties and attributes of class in accordance with XML definition.
FinalizeScript(ISimulationNode Parent, Model Model)
Executes model script, allowing for definitions that will be available across events.
override async Task Finalize()
Initialized the node before simulation.
override string LocalName
Local name of XML element defining contents of class.
override ISimulationNode Create(ISimulationNode Parent, Model Model)
Creates a new instance of the node.
Abstract base class for simulation nodes
ISimulationNode Parent
Parent node in the simulation model.
Class managing a script expression.
Definition: Expression.cs:39
async Task< object > EvaluateAsync(Variables Variables)
Evaluates the expression, using the variables provided in the Variables collection....
Definition: Expression.cs:4275
Basic interface for simulator nodes. Implementing this interface allows classes with default contruct...