Type := GETDOTNETTYPE(client); //Type2 := GETDOTNETTYPE(Irequest); //TypesArray2 := TypesArray2.CreateInstance(GETDOTNETTYPE(Type2),1); //TypesArray2.SetValue(Type2, 0); ParamsArray := ParamsArray.CreateInstance(GETDOTNETTYPE(Irequest),1); ParamsArray.SetValue(Irequest, 0); FOR i := 0 TO 60 DO BEGIN // could count them correctly using enumerator class, but it was 2am already when I wrote this MethodInfo := Type.GetMethods().GetValue(i); IF (MethodInfo.Name = 'Execute') THEN BEGIN BREAK; END; END; //MethodInfo := Type.GetMethod('Execute', TypesArray2); //this should work, but didn't in my case. if worked, you'd need to uncomment the previous comment block Iresponse := MethodInfo.Invoke(client,ParamsArray);
Type DotNet System.Type.'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' TypesArray DotNet System.Array.'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' Type2 DotNet System.Type.'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' TypesArray2 DotNet System.Array.'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' ParamsArray DotNet System.Array.'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' MethodInfo DotNet System.Reflection.MethodInfo.'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
Answers
Here are the variables (the important bits)
The idea:
You declare the Type as the type of your JToken class. Then you create an .net array and put all your method parameters. Then search through all the methods available for the class, and if they match the name ("Children", in your case), break the loop and actually execute the method.
Hope this helps
Wow, thanks!
I already saw this solution on a site but I did not quite understand how I have to do it.
But with your explanations I knew how to do it!