Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
ProductEvaluator.cs
5
7{
12 {
13 private IElement product = null;
14 private double doubleProduct = 0;
15 private bool isDouble = true;
16
22 : base(Node.Argument)
23 {
24 }
25
29 public override void RestartEvaluator()
30 {
31 this.product = null;
32 this.doubleProduct = 0;
33 this.isDouble = true;
34 }
35
40 public override void AggregateElement(IElement Element)
41 {
42 if (this.isDouble && Element is DoubleNumber D)
43 this.doubleProduct *= D.Value;
44 else if (this.product is null)
45 {
46 this.isDouble = false;
47
48 if (this.product is null)
49 this.product = Element;
50 else
51 this.product = Multiply.EvaluateMultiplication(new DoubleNumber(this.doubleProduct), Element, this.Node);
52 }
53 else
54 this.product = Multiply.EvaluateMultiplication(this.product, Element, this.Node);
55 }
56
60 public override IElement GetAggregatedResult()
61 {
62 if (this.isDouble)
63 return new DoubleNumber(this.doubleProduct);
64 else
65 return this.product ?? ObjectValue.Null;
66 }
67 }
68}
Base class for all types of elements.
Definition: Element.cs:14
override void RestartEvaluator()
Restarts the evaluator.
ProductEvaluator(Product Node)
Product(v) iterative evaluator
override void AggregateElement(IElement Element)
Aggregates one new element.
override IElement GetAggregatedResult()
Gets the aggregated result.
An interative evaluator of a function or operation defined by a single ScriptNode.
ScriptNode Node
Node being iteratively evaluated.
static readonly ObjectValue Null
Null value.
Definition: ObjectValue.cs:88
static IElement EvaluateMultiplication(IElement Left, IElement Right, ScriptNode Node)
Multiplies two operands.
Definition: Multiply.cs:69
Basic interface for all types of elements.
Definition: IElement.cs:21