This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static object InvokeInstanceMethod(object thisParameter, string methodName, Type[] typeArguments, params object[] args) { | |
CSharpArgumentInfo[] parameterFlags = new CSharpArgumentInfo[args.Length + 1]; | |
Expression[] parameters = new Expression[args.Length + 1]; | |
var thisParameterFlags = CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null); | |
parameterFlags[0] = thisParameterFlags; | |
parameters[0] = Expression.Constant(thisParameter); | |
for (int i = 0; i < args.Length; i++) { | |
parameterFlags[i + 1] = CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.Constant | CSharpArgumentInfoFlags.UseCompileTimeType, null); | |
parameters[i + 1] = Expression.Constant(args[i]); | |
} |