Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
Required.cs
2using System.Threading.Tasks;
6
8{
13 {
23 {
24 }
25
29 public override string FunctionName => nameof(Required);
30
37 {
38 IElement E = this.Argument.Evaluate(Variables);
39 if (E.AssociatedObjectValue is null)
40 throw new ScriptRuntimeException("Not defined.", this);
41
42 return E;
43 }
44
50 public override async Task<IElement> EvaluateAsync(Variables Variables)
51 {
52 IElement E = await this.Argument.EvaluateAsync(Variables);
53 if (E.AssociatedObjectValue is null)
54 throw new ScriptRuntimeException("Not defined.", this);
55
56 return E;
57 }
58
66 {
67 return Argument;
68 }
69
76 public override PatternMatchResult PatternMatch(IElement CheckAgainst, Dictionary<string, IElement> AlreadyFound)
77 {
78 if (CheckAgainst.AssociatedObjectValue is null)
79 return PatternMatchResult.NoMatch;
80
81 return this.Argument.PatternMatch(CheckAgainst, AlreadyFound);
82 }
83 }
84}
Class managing a script expression.
Definition: Expression.cs:41
Makes sure an expression is defined. Otherwise, an exception is thrown.
Definition: Required.cs:13
override IElement Evaluate(Variables Variables)
Evaluates the node, using the variables provided in the Variables collection.
Definition: Required.cs:36
override async Task< IElement > EvaluateAsync(Variables Variables)
Evaluates the node, using the variables provided in the Variables collection.
Definition: Required.cs:50
override PatternMatchResult PatternMatch(IElement CheckAgainst, Dictionary< string, IElement > AlreadyFound)
Performs a pattern match operation.
Definition: Required.cs:76
override string FunctionName
Name of the function
Definition: Required.cs:29
Required(ScriptNode Argument, int Start, int Length, Expression Expression)
Makes sure an expression is defined. Otherwise, an exception is thrown.
Definition: Required.cs:21
override IElement Evaluate(IElement Argument, Variables Variables)
Evaluates the function.
Definition: Required.cs:65
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:21
object AssociatedObjectValue
Associated object value.
Definition: IElement.cs:34
PatternMatchResult
Status result of a pattern matching operation.
Definition: ScriptNode.cs:17