Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
Char.cs
1using System;
2using System.IO;
3using System.Threading.Tasks;
4using System.Xml;
5using Waher.Script;
6
8{
13 {
14 private System.Char? value;
15 private Expression script;
16
23 : base(Parent, Model)
24 {
25 }
26
30 public override string LocalName => nameof(Char);
31
39 {
40 return new Char(Parent, Model);
41 }
42
47 public override Task FromXml(XmlElement Definition)
48 {
49 if (System.Char.TryParse(Definition.InnerText, out System.Char Value))
50 {
51 this.value = Value;
52 this.script = null;
53 }
54 else
55 {
56 this.value = null;
57 this.script = new Expression(Definition.InnerText);
58 }
59
60 return Task.CompletedTask;
61 }
62
68 public async Task Append(MemoryStream Output, Variables Variables)
69 {
70 object Result;
71
72 Output.Write(BitConverter.GetBytes(this.value ??
73 ((Result = await this.script.EvaluateAsync(Variables)) is System.Char Value ? Value :
74 Convert.ToChar(Result))), 0, 2);
75 }
76 }
77}
Root node of a simulation model
Definition: Model.cs:49
Abstract base class for simulation nodes
ISimulationNode Parent
Parent node in the simulation model.
Char(ISimulationNode Parent, Model Model)
Char value.
Definition: Char.cs:22
async Task Append(MemoryStream Output, Variables Variables)
Appends the binary element to the output stream.
Definition: Char.cs:68
override ISimulationNode Create(ISimulationNode Parent, Model Model)
Creates a new instance of the node.
Definition: Char.cs:38
override Task FromXml(XmlElement Definition)
Sets properties and attributes of class in accordance with Binary definition.
Definition: Char.cs:47
override string LocalName
Local name of Binary element defining contents of class.
Definition: Char.cs:30
Abstract base class for values
Definition: Value.cs:11
Class managing a script expression.
Definition: Expression.cs:39
Collection of variables.
Definition: Variables.cs:25
Basic interface for simulator nodes. Implementing this interface allows classes with default contruct...