Пример #1
0
        /// <summary>
        /// Visits <paramref name="expressions"/> and replaces <see cref="ParameterExpression"/> by <paramref name="newValues"/> performing match by <see cref="Expression.Type"/>
        /// </summary>
        internal static IEnumerable <Expression> ReplaceParameters(IEnumerable <Expression> expressions, IList <Expression> newValues)
        {
            return(newValues.Count != 0
                ? PerformReplacement()
                : expressions);

            IEnumerable <Expression> PerformReplacement()
            {
                var visitor = new ParameterReplacerVisitor(newValues);

                return(expressions.Where(o => o != null).Select(expression => visitor.Visit(expression)));
            }
        }
Пример #2
0
        internal static Expression ReplaceParameters(Expression expression, params Expression[] newValues)
        {
            var visitor = new ParameterReplacerVisitor(newValues);

            return(visitor.Visit(expression));
        }