Predicates/SimpleParser/Helpers/ExpressionAutoCast.cs
/// <summary>
/// Apply the cast to all the expressions, unless the type is already correct
/// </summary>
/// <param name="expressions">The input list of expressions</param>
/// <param name="type">The type to cast to</param>
/// <returns>The new list of expressions</returns>
Apply the cast to all the expressions, unless the type is already correct
Apply the cast to all the expressions unless the type is already correct
private static IList<Expression> CastTo(IEnumerable<Expression> expressions, Type type)
        {
            var result = new List<Expression>();
            foreach (var expression in expressions)
            {
                if (expression.Type == type)
                {
                    result.Add(expression);
                }
                else
                {
                    result.Add(Expression.Convert(expression, type));
                }
            }
            return result;
        }
private static IList < Expression > CastTo ( IEnumerable < Expression > expressions , Type type ) { var result = new List < Expression > ( ) ; foreach ( var expression in expressions ) { if ( expression . Type == type ) { result . Add ( expression ) ; } else { result . Add ( Expression . Convert ( expression , type ) ) ; } } return result ; }
Apply the cast to all the expressions, unless the type is already correct
Apply the cast to all the expressions unless the type is already correct
The new list of expressions
The new list of expressions
expressions
IEnumerable<Expression>
The input list of expressions
The input list of expressions
type
Type
The type to cast to
The type to cast to