Ejemplo n.º 1
0
        public List <EquationValidationError> SyntaxCheck(Data filter, Database storageMethod, WeightingFilterCollection weights)
        {
            try
            {
                EquationEvaluator evaluator = new EquationEvaluator(this);

                evaluator.Compile();

                /*string value = evaluator.Compile(
                 *  filter,
                 *  storageMethod,
                 *  weights
                 * );*/

                return(new List <EquationValidationError>());
            }
            catch (Exception ex)
            {
                List <EquationValidationError> result = new List <EquationValidationError>();

                result.Add(new EquationValidationError(EquationValidationErrorType.Syntax, ex.Message));

                return(result);
            }
        }
Ejemplo n.º 2
0
        public Equation(DatabaseCore.Core core, string equation, int weightMissingValue)
        {
            this.WeightMissingValue = weightMissingValue;
            this.CaseDataLocation   = core.CaseDataLocation;

            if (equation.Contains("return ") == false &&
                equation.Contains("double ") == false &&
                equation.Contains("int ") == false &&
                equation.Contains(" long") == false)
            {
                equation = "return " + equation + ";";
            }

            this.Core           = core;
            this.EquationString = equation.Replace("\n", " ").Replace("\r", " ");
            this.Values         = new Dictionary <string, EquationPlaceHolder>();

            this.ParsePlaceHolders();
            this.Validate();

            if (SecurityCheck(new Data(), new Database(core, null, 1), null).Count > 0)
            {
                //throw new Exception("InsecureEquationDetected");
                Log("<![CDATA[[InsecureEquationDetected]: " + this.EquationString + "]]>");
                return;
            }

            EquationEvaluator evaluator = new EquationEvaluator(this);

            try
            {
                this.Assembly = evaluator.Compile();
            }
            catch (Exception ex)
            {
                Log(string.Format(
                        "<Error><![CDATA[{0}]]></Error><Equation><![CDATA[{1}]]></Equation>",
                        ex.ToString(),
                        this.EquationString
                        ));
            }
        }