/// <summary> /// Takes a list of parameters from the source lamda expression and returns a list of parameters for the destination lambda expression. /// </summary> /// <param name="expression"></param> /// <param name="infoDictionary"></param> /// <param name="typeMappings"></param> /// <returns></returns> public static List <ParameterExpression> GetDestinationParameterExpressions(this LambdaExpression expression, MapperInfoDictionary infoDictionary, Dictionary <Type, Type> typeMappings) { foreach (var p in expression.Parameters.Where(p => !infoDictionary.ContainsKey(p))) { infoDictionary.Add(p, typeMappings); } return(expression.Parameters.Select(p => infoDictionary[p].NewParameter).ToList()); }
/// <summary> /// Takes a list of parameters from the source lamda expression and returns a list of parameters for the destination lambda expression. /// </summary> /// <param name="expression"></param> /// <param name="infoDictionary"></param> /// <param name="typeMappings"></param> /// <returns></returns> public static List <ParameterExpression> GetDestinationParameterExpressions(this LambdaExpression expression, MapperInfoDictionary infoDictionary, Dictionary <Type, Type> typeMappings) { foreach (ParameterExpression p in expression.Parameters) { if (!infoDictionary.ContainsKey(p))//possible cases where the parameter has not been used in the body. { infoDictionary.Add(p, typeMappings); } } return(expression.Parameters.Select(p => infoDictionary[p].NewParameter).ToList()); }