Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
Year.cs
1using System.Threading.Tasks;
6
8{
13 {
22 : base(Argument, Start, Year, Expression)
23 {
24 }
25
29 public override string FunctionName => nameof(Year);
30
34 public override string[] Aliases => new string[] { "Years" };
35
43 {
44 if (Argument.AssociatedObjectValue is System.DateTime TP)
45 return new DoubleNumber(TP.Year);
46 else if (Argument.AssociatedObjectValue is System.DateTimeOffset TPO)
47 return new DoubleNumber(TPO.Year);
48 else if (Argument.AssociatedObjectValue is IYears D)
49 return new DoubleNumber(D.Years);
50 else
51 throw new ScriptRuntimeException("Unable to extract number of years.", this);
52 }
53
60 public override Task<IElement> EvaluateScalarAsync(IElement Argument, Variables Variables)
61 {
62 return Task.FromResult(this.EvaluateScalar(Argument, Variables));
63 }
64 }
65}
Class managing a script expression.
Definition: Expression.cs:39
Year(ScriptNode Argument, int Start, int Year, Expression Expression)
Year(x)
Definition: Year.cs:21
override string FunctionName
Name of the function
Definition: Year.cs:29
override Task< IElement > EvaluateScalarAsync(IElement Argument, Variables Variables)
Evaluates the function on a scalar argument.
Definition: Year.cs:60
override IElement EvaluateScalar(IElement Argument, Variables Variables)
Evaluates the function on a scalar argument.
Definition: Year.cs:42
override string[] Aliases
Optional aliases. If there are no aliases for the function, null is returned.
Definition: Year.cs:34
Base class for funcions of one scalar variable.
ScriptNode Argument
Function argument.
Base class for all nodes in a parsed script tree.
Definition: ScriptNode.cs:69
int Start
Start position in script expression.
Definition: ScriptNode.cs:92
Collection of variables.
Definition: Variables.cs:25
Basic interface for all types of elements.
Definition: IElement.cs:20
Interface for objects having a Years component.
Definition: IYears.cs:7