My problem is like this:
In ASP DetailsView component we have three different EventArgs for different DB operations:
DetailsViewInsertedEventArgs, DetailsViewDeletedEventArgs, DetailsViewUpdatedEventArgs.
All above EventArgs have common properites, I am interested in two of them: Exception and ExceptionHandled. Unfortunately those two properties are not existant in the common ancestor for those event args.
I would like to create a method like this:
public void DoSomething(ref CommonAncestorForDVArgs args)
{
if (args.Exception != null)
{
//do something with an exception
args.ExceptionHandled = true;
}
}
Of course this is not possible due to the fact that I’ve described earlier.
Solution which I came up with is this:
public void DoSomething(Exception e, bool ExceptionHandled)
{
if (e.Exception != null)
{
//do something with an exception
ExceptionHandled = true;
}
}
But I am wonder if there is something better?
Alternatively, use Reflection:
In terms of maintenance, it’s probably not that much different from my other answer.