private static MethodCallCSharpExpression MakeAccess(ConditionalReceiver receiver, MethodInfo method, ReadOnlyCollection <ParameterAssignment> arguments) { if (method.IsStatic && method.IsDefined(typeof(ExtensionAttribute))) { var thisPar = method.GetParametersCached()[0]; var thisArg = CSharpExpression.Bind(thisPar, receiver); var newArgs = new ParameterAssignment[arguments.Count + 1]; newArgs[0] = thisArg; var i = 1; foreach (var arg in arguments) { newArgs[i++] = arg; } var newArguments = new TrueReadOnlyCollection <ParameterAssignment>(newArgs); return(CSharpExpression.Call(null, method, newArguments)); // TODO: call ctor directly } else { return(CSharpExpression.Call(receiver, method, arguments)); // TODO: call ctor directly } }
/// <summary> /// Creates a new expression that is like this one, but using the supplied children. If all of the children are the same, it will return this expression. /// </summary> /// <param name="object">The <see cref="Object" /> property of the result.</param> /// <param name="arguments">The <see cref="Arguments" /> property of the result.</param> /// <returns>This expression if no children changed, or an expression with the updated children.</returns> public MethodCallCSharpExpression Update(Expression @object, IEnumerable <ParameterAssignment> arguments) { if (@object == Object && arguments == Arguments) { return(this); } return(CSharpExpression.Call(@object, Method, arguments)); }