Exemple #1
0
        private static FormulaValue RunAggregator(IAggregator agg, EvalVisitor runner, SymbolContext context, IRContext irContext, FormulaValue[] args)
        {
            var arg0 = (TableValue)args[0];
            var arg1 = (LambdaFormulaValue)args[1];

            foreach (DValue <RecordValue> row in arg0.Rows)
            {
                if (row.IsValue)
                {
                    var childContext = context.WithScopeValues(row.Value);
                    var value        = arg1.Eval(runner, childContext);

                    if (value is NumberValue number)
                    {
                        value = FiniteChecker(irContext, 0, number);
                    }

                    if (value is ErrorValue error)
                    {
                        return(error);
                    }
                    agg.Apply(value);
                }
            }

            return(agg.GetResult(irContext));
        }
Exemple #2
0
 private static FormulaValue RunAggregator(IAggregator agg, IRContext irContext, FormulaValue[] values)
 {
     foreach (var value in values)
     {
         agg.Apply(value);
     }
     return(agg.GetResult(irContext));
 }
Exemple #3
0
            public object GetResult()
            {
                var sum = _sumAggregator.GetResult();

                if (sum == null)
                {
                    return(null);
                }

                _sumArgument.Value   = Convert.ChangeType(sum, _sumArgument.Type);
                _countArgument.Value = Convert.ChangeType(_countAggregator.GetResult(), _countArgument.Type);
                return(_divisionExpression.Evaluate());
            }