Represents a node in the abstract syntax tree.
Exemplo n.º 1
0
        public LogicalBindaryExpression(Expression left, Expression right, LogicalOperator @operator)
        {
            Require.NotNull(left, "left");
            Require.NotNull(right, "right");

            Left = left;
            Right = right;
            Operator = @operator;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Evalute the value of the specified condition expression.
        /// </summary>
        /// <param name="expression">The condition expression to evaluate.</param>
        /// <param name="dataContext">The context object.</param>
        /// <returns>True if the the condition passed, false otherwise.</returns>
        public bool Evaluate(Expression expression, object dataContext)
        {
            Require.NotNull(expression, "expression");
            Require.NotNull(dataContext, "dataContext");

            _dataContext = dataContext;

            var dataContextType = dataContext.GetType();
            _availableParameters = _parameterProviders.SelectMany(x => x.GetParameters(dataContextType))
                                                      .DistinctBy(x => x.Name)
                                                      .ToList();

            Visit(expression);

            Debug.Assert(_results.Count == 1);

            return _results.Pop();
        }
Exemplo n.º 3
0
 protected virtual void Visit(Expression exp)
 {
     exp.Accept(this);
 }
Exemplo n.º 4
0
 void IExpressionVisitor.Visit(Expression exp)
 {
     Visit(exp);
 }
Exemplo n.º 5
0
        public bool Evaluate(Expression expression, object dataContext)
        {
            Require.NotNull(expression, "expression");
            Require.NotNull(dataContext, "dataContext");

            var evaluator = new ExpressionEvaluator(ParameterProviders, ComparisonOperators);
            return evaluator.Evaluate(expression, dataContext);
        }