I'm writing a utility program. In fact, the program will be a Console application that will contain many static methods, each method being a specific utility.
The application will take two command line arguments: filename, and utility name. Of course I want to run the method specified on the file specified.
I want to discuss approaches to this. Each method may have a unique signature and return value/type.
Thinking through this, I need a way to
1) check to see if the method on the commandline exists in the program. I could create an array of all method names, and check against the array. Simple enough, but is there a more elegant way? Does a class contain knowledge of its own members?
2) invoke any particular method, given a string. That string would be the method name.
How would I know what parameters I need to pass to the method? They wouldn't come from the commandline. I need some way of knowing, gathering, and passing in all required parameters/objects.
What I'm thinking is that the Main() method will declare a FileStream, plus any other objects that may be needed by any of the utility methods. I need some way to "map" these objects to the parameters needed by the method I want to call.
Again, I could create some data structure that said "if arg equals this string, then call this method with these parameters". The problem is that becomes more to maintain. When a new utility is added to the program, I'll have to write the utility method, PLUS define any new objects the utility may need in Main(), PLUS update the structure that maps arg to the new method. I'm looking for clever ways to avoid that final step.
I'm looking for other ideas, pointers to articles, general discussion, anything that would help me to think through this project.