I want to make a class that has the ability to dynamically call methods in other classes by name. Ideally, it would accept the class and method names as well as a collection of parameters. dictClass works well for this on static methods, but doesn't seem to work on instance methods.
Is there any way to make the following code work for non-static methods?
|
The following code should do the trick. The code I have below can either use a class name or take in an object of the desired type that is already instantiated.
The largest problem was dealing with passing the parameters along. Since there are a variable number I am using a switch statement to pass the correct number of parameters to the method. This doesn't look very elegant, but I am not sure there is another way to accomplish this.
|
Also try looking into DictClass.MakeObject:
| |||||||||
|