reflection invoke methods with arrays as arguments
Monkey Forums/Monkey Programming/reflection invoke methods with arrays as arguments
| ||
This has me stumped, how would I go about invoking a method like this: [bbcode] Method testMethod : Void( a : int, b : float[] ) [/bbcode] BoxInt is fine for the first parameter but how would I handle the array? I can't see how to do this from the commands in reflection. Thank you for any assistance, this is making my brain hurt! |
| ||
Here's a runnable example. As you're using a class, you will need to replace FunctionInfo with MethodInfo and GetFunction with GetMethod, etc. Strict #REFLECTION_FILTER="*" Import reflection Function Main:Int() Local argumentTypes:ClassInfo[] =[IntClass(), ArrayClass("Float")] Local functionInfo:FunctionInfo = GetFunction("TestFunc", argumentTypes) Local myInt:Int = 42 Local myArray:Float[] =[1.2, 3.4] functionInfo.Invoke([IntObject(myInt), ArrayBoxer<Float>.Box(myArray)]) Return 0 End Function TestFunc:Void(a:int, b:float[]) Print "a:" + a + " b[1]:" + b[1] End |
| ||
Thank you, ArrayBoxer was what I was looking for :) |