I have a class that has about 20-some methods in it. Each one does some web service message processing. I just had to make a change to it, and realized that every one of these m
What you can do is write the above code in a method that takes a Action or a Func as a parameter which determines the method that should be called in the throw block, along with its parameters.
So that if you would call M(1, "string")
in your throw block, it becomes DoStuff(M, 1, "string")
DoStuff would look like
void DoStuff(Func myMethod, T1 arg1, T2 arg2)
{
try
{
myMethod(arg1, arg2)
}
catch (FaultException cfex)
{
// common stuff
}
catch (CustomException cfex)
{
// common stuff
}
catch (Exception ex)
{
// common stuff
}
finally
{
FinalizeServiceCall(wsBus, wsMessage, response, logProps);
}
}