Inheritance: ExpressionVisitor
示例#1
0
        public object Execute(Expression expression, bool isEnumerable)
        {
            var whereVisitor = new WhereVisitor();
            var methodCallExpression = whereVisitor.FindWhere(expression);

            LambdaExpression lambdaExpression =
                (LambdaExpression)
                ((UnaryExpression) methodCallExpression.Arguments[1]).Operand;

            var idFinder = new IdExpressionVisitor();
            if(idFinder.FindIdExpression(lambdaExpression))
            {
                string id = IdFromExpression(idFinder.Expressions.First());

                Status status = _linqApi.GetStatus(id);

                if (isEnumerable)
                {
                    return new[] {status};
                }
                return status;
            }

            return null;
        }
示例#2
0
        private void HandleWhereArgs(Expression expression, TimeLineArgs args)
        {
            var whereVisitor = new WhereVisitor();

            MethodCallExpression whereExpression = whereVisitor.FindWhere(expression);
            if (whereExpression == null)
            {
                return;
            }

            LambdaExpression lambdaExpression =
                (LambdaExpression)
                ((UnaryExpression)whereExpression.Arguments[1]).Operand;

            var idVisitor = new IdExpressionVisitor();
            if (!idVisitor.FindIdExpression(lambdaExpression))
            {
                return;
            }

            foreach (BinaryExpression binaryExpression in idVisitor.Expressions)
            {
                BuildArgs(binaryExpression, args);
            }
        }