public Expression ConvertMethodParameters(OverloadResolutionData <MethodInfo> resolvedMethod, Expression target, DynamicMetaObject[] args)//, Type[] argTypeArray) { if (resolvedMethod == null) { throw new ArgumentNullException(nameof(resolvedMethod)); } if (args == null) { throw new ArgumentNullException(nameof(args)); } var argExpressions = _overloadResolver.CreateParameterExpressions(resolvedMethod, args); var method = resolvedMethod.FunctionMember; Expression result = Expression.Call( VelocityExpressions.ConvertIfNeeded(target, method.DeclaringType), method, argExpressions ); if (method.ReturnType == typeof(void)) { result = Expression.Block( result, Constants.VoidReturnValue ); } return(result); }
private Expression IndexExpression(DynamicMetaObject target, DynamicMetaObject[] args, IEnumerable <PropertyInfo> candidateProperties) { var typeArgs = args.Select(x => x.LimitType).ToImmutableArray(); var candidateData = candidateProperties.Select(x => new FunctionMemberData <PropertyInfo>(x, x.GetIndexParameters())); var result = _overloadResolver.Resolve(candidateData, typeArgs); if (result == null) { return(null); } var argExpressions = _overloadResolver.CreateParameterExpressions(result, args); var indexer = result.FunctionMember; var targetExpression = VelocityExpressions.ConvertIfNeeded(target.Expression, indexer.DeclaringType); return(Expression.MakeIndex(targetExpression, indexer, argExpressions)); }