I’m working with a third-party library interfacing to an old database system. There’s a method – CallProg that calls a “stored procedure” (for lack of a better translation – any Pick users in the crowd?). However, instead of doing something like this:
Public Sub CallProg(ProgName, ParamArray ProgArgs() As String)
...
End Sub
or even this:
Public Sub CallProg(ProgName, Optional Arg1 As String, Optional Arg2 As String ... Optional Arg20 As String)
They did this:
Public Sub CallProg(ProgName)
Public Sub CallProg(ProgName, Arg1 As String)
Public Sub CallProg(ProgName, Arg1 As String, Arg2 As String)
Public Sub CallProg(ProgName, Arg1 As String, Arg2 As String, Arg3 As String)
...
Public Sub CallProg(ProgName, Arg1 As String, ... Arg20 As String)
I’m writing an abstraction class to handle logging in, setting the environment, etc., so it can be used as a generic “helper” class in a number of other projects. Is there any way to wrap the CallProg sub that doesn’t involve 20 overloads?
This is a very quick idea of how to do it using reflection. I’m not sure if its the best way but it should work…
End Class
Public Class Test1
End Class