Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
Required.cs
1using System.Collections.Generic;
2using System.Threading.Tasks;
7
9{
14 {
24 {
25 }
26
30 public override string FunctionName => nameof(Required);
31
38 {
39 IElement E = this.Argument.Evaluate(Variables);
40 if (E.AssociatedObjectValue is null)
41 throw new ScriptRuntimeException("Not defined.", this);
42
43 return E;
44 }
45
51 public override async Task<IElement> EvaluateAsync(Variables Variables)
52 {
53 IElement E = await this.Argument.EvaluateAsync(Variables);
54 if (E.AssociatedObjectValue is null)
55 throw new ScriptRuntimeException("Not defined.", this);
56
57 return E;
58 }
59
67 {
68 return Argument;
69 }
70
77 public override PatternMatchResult PatternMatch(IElement CheckAgainst, Dictionary<string, IElement> AlreadyFound)
78 {
79 if (CheckAgainst.AssociatedObjectValue is null)
80 return PatternMatchResult.NoMatch;
81
82 return this.Argument.PatternMatch(CheckAgainst, AlreadyFound);
83 }
84 }
85}
Class managing a script expression.
Definition: Expression.cs:39
Makes sure an expression is defined. Otherwise, an exception is thrown.
Definition: Required.cs:14
override IElement Evaluate(Variables Variables)
Evaluates the node, using the variables provided in the Variables collection.
Definition: Required.cs:37
override async Task< IElement > EvaluateAsync(Variables Variables)
Evaluates the node, using the variables provided in the Variables collection.
Definition: Required.cs:51
override PatternMatchResult PatternMatch(IElement CheckAgainst, Dictionary< string, IElement > AlreadyFound)
Performs a pattern match operation.
Definition: Required.cs:77
override string FunctionName
Name of the function
Definition: Required.cs:30
Required(ScriptNode Argument, int Start, int Length, Expression Expression)
Makes sure an expression is defined. Otherwise, an exception is thrown.
Definition: Required.cs:22
override IElement Evaluate(IElement Argument, Variables Variables)
Evaluates the function.
Definition: Required.cs:66
Base class for funcions of one variable.
ScriptNode Argument
Function argument.
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
virtual PatternMatchResult PatternMatch(IElement CheckAgainst, Dictionary< string, IElement > AlreadyFound)
Performs a pattern match operation.
Definition: ScriptNode.cs:169
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
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
PatternMatchResult
Status result of a pattern matching operation.
Definition: ScriptNode.cs:17