protected override void Visit(ComparisonExpression exp)
        {
            var paramName = exp.Param.ParamName;
            var param = _availableParameters.FirstOrDefault(x => x.Name == paramName);
            if (param == null)
                throw new UnrecognizedParameterException("Unrecognized parameter \"" + paramName + "\" or it's not accessable in currect context.");

            var @operator = _comparisonOperators.Find(exp.Operator);
            if (@operator == null)
                throw new UnrecognizedComparisonOperatorException("Unrecognized comparison operator \"" + exp.Operator + "\".");

            var result = false;

            var paramValue = param.ResolveValue(_dataContext);
            if (paramValue != null)
            {
                var paramType = paramValue.GetType();
                object conditionValue = null;

                if (paramType.IsEnum)
                {
                    conditionValue = Enum.Parse(paramType, exp.Value.Value);
                }
                else
                {
                    conditionValue = Convert.ChangeType(exp.Value.Value, paramType);
                }

                result = @operator.Apply(param, paramValue, conditionValue);
            }

            _results.Push(result);
        }
 protected virtual void Visit(ComparisonExpression exp)
 {
 }
 void IExpressionVisitor.Visit(ComparisonExpression exp)
 {
     Visit(exp);
 }
        // Comparison is the most nested level
        protected override void Visit(ComparisonExpression exp)
        {
            var model = new ComparisonModel
            {
                ParamName = exp.Param.ParamName,
                Value = exp.Value.Value,
                Operator = exp.Operator
            };

            var op = _comparisonOperators.Find(exp.Operator);
            if (op != null)
            {
                model.OperatorDisplayName = op.Name;
                if (!String.IsNullOrWhiteSpace(op.Alias))
                {
                    model.OperatorDisplayName = op.Alias;
                }
            }

            var param = _parameters.Find(x => x.Name.Equals(model.ParamName, StringComparison.OrdinalIgnoreCase));
            if (param != null)
            {
                model.ValueType = param.ValueType.FullName;
                model.IsNumberValue = param.ValueType.IsNumericType();
            }

            _stack.Push(model);
        }
Exemple #5
0
 void IExpressionVisitor.Visit(ComparisonExpression exp)
 {
     Visit(exp);
 }
Exemple #6
0
 protected virtual void Visit(ComparisonExpression exp)
 {
 }