Background
I'm building an automation framework (just a bunch of C# classes/interfaces) to drive a desktop application using Appium and WinAppDriver. One of the awesome features offered by Appium/WinAppDriver is the ability to take a screenshot of the running application at any time. I want to easily toggle on/off screenshot capture upon every method call of my automation framework without altering every method of my automation framework because that is effort and a lot of code duplication and also pretty boring.
Ideal solution
I'd like to use the magic that is reflection (or a third party library if one exists) to write a piece of code that says before executing any method on this object, execute this other piece of code
. Is this even possible?