Esempio n. 1
0
        protected override Expression VisitMethodCall(MethodCallExpression node)
        {
            var mi = node.Method;

            if (mi.IsGenericMethod)
            {
                Type[] changedTypes = ReflectionX.SubstituteTypes(mi.GetGenericArguments(), from, to);
                if (changedTypes != null)
                {
                    MethodInfo newMi = mi.GetGenericMethodDefinition().MakeGenericMethod(changedTypes);
                    if (node.Object == null)
                    {
                        return(Expression.Call(newMi,
                                               node.Arguments.Select(a => Visit(a))));
                    }
                    else
                    {
                        return(Expression.Call(node.Object, newMi,
                                               node.Arguments.Select(a => Visit(a))));
                    }
                }
            }
            return(base.VisitMethodCall(node));
        }