public static bool TryCreate(
            Expression unary,
            Expression root,
            out UnaryExpressionCloner result)
        {
            if (unary == null)
            {
                result = null;
                return(false);
            }

            Expression expr = unary;

            do
            {
                // Check if we reached the root expression
                if (expr == root)
                {
                    result = new UnaryExpressionCloner(unary, root);
                    return(true);
                }
            }while (TryGetNextStep(expr, out expr));

            // Last chance: check for a default root node
            if (root == null && IsValidDefaultNode(expr))
            {
                result = new UnaryExpressionCloner(unary, expr);
                return(true);
            }

            result = null;
            return(false);
        }
예제 #2
0
        public static bool TryCreate(
            Expression unary, 
            Expression root, 
            out UnaryExpressionCloner result)
        {
            if (unary == null)
            {
                result = null;
                return false;
            }

            Expression expr = unary;

            do
            {
                // Check if we reached the root expression
                if (expr == root)
                {
                    result = new UnaryExpressionCloner(unary, root);
                    return true;
                }
            }
            while (TryGetNextStep(expr, out expr)) ;

            // Last chance: check for a default root node
            if (root == null && IsValidDefaultNode(expr))
            {
                result = new UnaryExpressionCloner(unary, expr);
                return true;
            }

            result = null;
            return false;
        }