I have the following methods that work:
Private Delegate Function WebMethodDelegate(Of TRequest, TResponse)(ByVal request As TRequest) As TResponse
Private Function CallWebMethod(Of TRequest, TResponse)(ByVal request As TRequest, ByVal theMethodToRun As WebMethodDelegate(Of TRequest, TResponse)) As TResponse
Dim response As TResponse = Nothing
'begin pseudocode
While somtthing is true
response = theMethodToRun.Invoke(Request)
End While
'end pseudocode
End Function
I call the above with (an ugly call):
Dim webMethodDeletgate As New WebMethodDelegate(Of wsLookupServiceProxy.RequestBase, wsLookupServiceProxy.GetSelectedLookupInfoResponseOfTitle)(AddressOf _service.GetAllTitles)
CallWebMethod(Of wsLookupServiceProxy.RequestBase, wsLookupServiceProxy.GetSelectedLookupInfoResponseOfTitle)(request, webMethodDeletgate)
I thought about doing this:
Dim requestType As Type = GetType(wsLookupServiceProxy.RequestBase)
Dim responseType As Type = GetType(wsLookupServiceProxy.GetSelectedLookupInfoResponseOfTitle)
Dim webMethodDeletgate As New WebMethodDelegate(Of requestType, responseType)(AddressOf _service.GetAllTitles)
CallWebMethod(Of requestType, responseType)(request, webMethodDeletgate)
But the compiler didn’t like it.
I wondered if anyone can provide a cleaner way to call the method, without having the hugely long method call?
Thanks in advance.
Well by using
at the top of your class you can get this down to
You can also remove the
(Of TResult, TResponse)from the method call since those are determinable from thewebMehtodDelegate