Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
NullCheck.cs
1using System;
2using System.Threading.Tasks;
5
7{
12 {
22 : base(Left, Right, Start, Length, Expression)
23 {
24 }
25
32 {
33 IElement Left;
34
35 try
36 {
37 Left = this.left.Evaluate(Variables);
38 }
39 catch (Exception)
40 {
41 return this.right.Evaluate(Variables);
42 }
43
44 if (!(Left.AssociatedObjectValue is null))
45 return Left;
46
47 IElement Right = this.right.Evaluate(Variables);
48
49 return this.Evaluate(Left, Right, Variables);
50 }
51
57 public override async Task<IElement> EvaluateAsync(Variables Variables)
58 {
59 IElement Left;
60
61 try
62 {
63 Left = await this.left.EvaluateAsync(Variables);
64 }
65 catch (Exception)
66 {
67 return await this.right.EvaluateAsync(Variables);
68 }
69
70 if (!(Left.AssociatedObjectValue is null))
71 return Left;
72
73 IElement Right = await this.right.EvaluateAsync(Variables);
74
75 return await this.EvaluateAsync(Left, Right, Variables);
76 }
77
86 {
87 if (Left.AssociatedObjectValue is null)
88 return Right;
89 else
90 return Left;
91 }
92
96 public override UpgradeBehaviour ScalarUpgradeBehaviour => UpgradeBehaviour.DifferentTypesOk;
97 }
98}
Class managing a script expression.
Definition: Expression.cs:39
ScriptNode right
Right operand.
ScriptNode left
Left operand.
Base class for binary scalar operators.
Base class for all nodes in a parsed script tree.
Definition: ScriptNode.cs:69
int Length
Length of expression covered by node.
Definition: ScriptNode.cs:101
int Start
Start position in script expression.
Definition: ScriptNode.cs:92
abstract IElement Evaluate(Variables Variables)
Evaluates the node, using the variables provided in the Variables collection. This method should be ...
virtual Task< IElement > EvaluateAsync(Variables Variables)
Evaluates the node, using the variables provided in the Variables collection. This method should be ...
Definition: ScriptNode.cs:158
override async Task< IElement > EvaluateAsync(Variables Variables)
Evaluates the node, using the variables provided in the Variables collection.
Definition: NullCheck.cs:57
override IElement EvaluateScalar(IElement Left, IElement Right, Variables Variables)
Evaluates the operator on scalar operands.
Definition: NullCheck.cs:85
NullCheck(ScriptNode Left, ScriptNode Right, int Start, int Length, Expression Expression)
Binary null check operator.
Definition: NullCheck.cs:21
override IElement Evaluate(Variables Variables)
Evaluates the node, using the variables provided in the Variables collection.
Definition: NullCheck.cs:31
override UpgradeBehaviour ScalarUpgradeBehaviour
How scalar operands of different types are to be treated. By default, scalar operands are required to...
Definition: NullCheck.cs:96
Collection of variables.
Definition: Variables.cs:25
Basic interface for all types of elements.
Definition: IElement.cs:20
object AssociatedObjectValue
Associated object value.
Definition: IElement.cs:33
UpgradeBehaviour
How operands are to be handled if not of the same type.