Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
 protected virtual void Visit(ComparisonExpression exp)
 {
 }
Ejemplo n.º 3
0
 void IExpressionVisitor.Visit(ComparisonExpression exp)
 {
     Visit(exp);
 }
Ejemplo n.º 4
0
        // 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);
        }
Ejemplo n.º 5
0
 void IExpressionVisitor.Visit(ComparisonExpression exp)
 {
     Visit(exp);
 }
Ejemplo n.º 6
0
 protected virtual void Visit(ComparisonExpression exp)
 {
 }