I have multiple calls to methods in a 3rd party library.
These methods have a wide variety of different signatures / parameter combinations.
There are specific errors that the 3rd party library generates that I would like to catch and handle, and since the resolution is the same I would like it to take place in a single handler.
So I want to be able to have a method that essentially takes in as parameters a function (delegate) and its arguments, and invokes it inside some try/catch logic.
I don’t know if its just not possible or I’m not getting the syntax right, but I can’t figure out how to handle the fact that the signature for each method being passed in is different.
Any suggestions?
You could use
ActionandFunc<T>to wrap the methods, and closures to pass arguments.You could then use this via:
Edit: The above was assuming you were wrapping an instance of the third party library. Given (from your comments) that these are static methods, you can just use:
And then call via: