public static DmlfConditionBase ParseFilterExpression(FilterParserType type, DmlfExpression columnValue, string expression, ParserOptions options)
        {
            var opts = new FilterParseOptions();

            switch (type)
            {
            case FilterParserType.String:
                opts.ParseString = true;
                break;

            case FilterParserType.Number:
                opts.ParseNumber = true;
                break;

            case FilterParserType.DateTime:
                opts.ParseTime = true;
                break;

            case FilterParserType.Logical:
                opts.ParseLogical = true;
                break;

            default:
                throw new Exception("DBSH-00000 Unexpected filter parser type:" + type);
            }
            var parser = new DmlfFilterParser(expression, columnValue, opts);

            parser.Run();
            return(parser.Result);
        }
Exemple #2
0
        private bool TestCondition(FilterParserType type, string condition, object testedValue)
        {
            var cond = FilterParserTool.ParseFilterExpression(type, new DmlfPlaceholderExpression(), condition);
            var ns   = new DmlfSingleValueNamespace(testedValue);

            Assert.NotNull(cond);
            return(cond.EvalCondition(ns));
        }
Exemple #3
0
        public static DmlfConditionBase ParseFilterExpression(FilterParserType type, DmlfExpression columnValue, string expression, ParserOptions options = null)
        {
            if (expression == null)
            {
                return(null);
            }
            expression = TransformExpression(expression);
            var res = FilterParserCoreImpl.ParseFilterExpression(type, columnValue, expression, options);

            if (res != null)
            {
                res = res.SimplifyCondition();
            }
            return(res);
        }