I'm working in VB.Net and I'm trying to make a piece of code more generic.
In fact, there's a big Select Case statement that build a ProxyServer based on a value passed in parameter (a string).
Select Case _strNteraHL7
Case Constantes.NomPRPMIN306010
strUrl = ObtenirUrl("ProviderDetailsQuery", _strVersion, _strEnvir, True, _blnSimulCAIS, _blnSimulPDS, _blnSimulPDSSIIR, _blnSimulPDSInteg)
objWsHL7 = New wsProviderDetailsQuery.ProviderDetailsQueryClient(objBinding, New EndpointAddress(strUrl))
Case Constantes.NomPRPMIN301010
strUrl = ObtenirUrl("AddProvider", _strVersion, _strEnvir, True, _blnSimulCAIS, _blnSimulPDS, _blnSimulPDSSIIR, _blnSimulPDSInteg)
objWsHL7 = New wsAddProvider.AddProviderClient(objBinding, New EndpointAddress(strUrl))
The objects like "wsAddProvider" and "wsProviderDetailsQuery" in the previous example are service references that have been added through the GUI of Visual Studio...
What I want to know, is basically, if I can call this constructor from a certain pool containing service references, similar as when I want to call a control in a controls container...
for example:
objWsHL7 = new wcfServicesContainer("serviceNameHere", paramArray())
or something similar, so I can remove all those big switch cases, that repeat the same thing 30 times.
objWsHL7 being an object or type "object" at compiling.
Sorry if I didn't mention enough detail, feel free to let me know if you need more, I don't really know what information I have to provide for this.
Edit: I've spotted another piece of code here that uses similar calls, maybe it'll help understanding...
Again, in another switch case statement,
objMsgHL7Out = _objWsHL7.ProviderDetailsQuery(_objMsgIn)
objMsgHL7Out is a System.ServiceModel.Channels.Message _objMsgIn is a System.ServiceModel.Channels.Message _objWsHL7 is an Object