Beispiel #1
0
        /// <summary>
        /// Translate a fully formed expression. Partial expressions
        /// are not trnaslated, however!
        /// </summary>
        /// <param name="expr"></param>
        /// <param name="cookies">List of cookies - a trail of variable renames we've done</param>
        /// <returns></returns>
        public static Expression Translate(Expression expr, List <string> cookies, Func <Expression, Expression> resolver)
        {
            // Remove Tuple's and custom objects.
            var exprObjsRemoved = ObjectPropertyExpressionVisitor.RemoveObjectAndTupleReferences(expr);

            // Now, do our custom translations.
            var oldResolver = _impl.Value.Resolver;

            _impl.Value.Resolver = resolver;

            var oldRenameList = _impl.Value.RenameList;

            _impl.Value.RenameList = new List <string>();

            try {
                var result = _impl.Value.Visit(exprObjsRemoved);

                // Track all cookies going out!
                cookies.AddRange(_impl.Value.RenameList);
                return(result);
            }
            finally
            {
                // Reset to previous state.
                _impl.Value.Resolver   = oldResolver;
                _impl.Value.RenameList = oldRenameList;
            }
        }
 /// <summary>
 /// Run the expression.
 /// </summary>
 /// <param name="xpr"></param>
 /// <returns></returns>
 Expression DoTranslate(Expression expr)
 {
     // Remove Tuple's and similar things.
     var objlift = new ObjectPropertyExpressionVisitor();
     var exprObjsRemoved = objlift.VisitExpression(expr);
     return exprObjsRemoved;
 }
        /// <summary>
        /// Run the expression.
        /// </summary>
        /// <param name="xpr"></param>
        /// <returns></returns>
        Expression DoTranslate(Expression expr)
        {
            // Remove Tuple's and similar things.
            var objlift         = new ObjectPropertyExpressionVisitor();
            var exprObjsRemoved = objlift.VisitExpression(expr);

            return(exprObjsRemoved);
        }