Ejemplo n.º 1
0
        public bool ExpressionEvaluator(Parameter parameter)
        {
            CodingSeb.ExpressionEvaluator.ExpressionEvaluator expressionEvaluator = new CodingSeb.ExpressionEvaluator.ExpressionEvaluator();

            List <int> results = new List <int>(parameter.Statements.Length);

            foreach (string statement in parameter.Statements)
            {
                int result = expressionEvaluator.Evaluate <int>(statement);

                results.Add(result);
            }

            return(Assert(results, parameter.Sum));
        }
Ejemplo n.º 2
0
        public bool ExpressionEvaluator(Parameter parameter)
        {
            CodingSeb.ExpressionEvaluator.ExpressionEvaluator expressionEvaluator = new CodingSeb.ExpressionEvaluator.ExpressionEvaluator();
            expressionEvaluator.Variables["n"] = parameter.Numbers;

            List <int> results = new List <int>(parameter.Numbers.Length);

            foreach (int number in parameter.Numbers)
            {
                int result = expressionEvaluator.Evaluate <int>(parameter.Statements[number]);

                results.Add(result);
            }

            return(Assert(results, parameter.Sum));
        }
Ejemplo n.º 3
0
        private void bCalcExpressionEvaluator_Click(object sender, EventArgs e)
        {
            try
            {
                SetData();
                var evaluator = new CodingSeb.ExpressionEvaluator.ExpressionEvaluator();
                evaluator.OptionStringEvaluationActive           = false;
                evaluator.OptionCharEvaluationActive             = false;
                evaluator.OptionEvaluateFunctionActive           = false;
                evaluator.OptionVariableAssignationActive        = false;
                evaluator.OptionScriptEvaluateFunctionActive     = false;
                evaluator.OptionInlineNamespacesEvaluationActive = false;
                evaluator.Namespaces.Clear();
                evaluator.PreEvaluateFunction += Evaluator_PreEvaluateFunction;
                evaluator.PreEvaluateVariable += Evaluator_PreEvaluateVariable;
                var formula = tbFormula.Text;

                // WHERE processing.
                var indexWhere = formula.IndexOf("WHERE", StringComparison.OrdinalIgnoreCase);
                if (indexWhere > -1)
                {
                    var wherePart = formula[(indexWhere + 5)..^ 0].Trim();