So what I'm trying to do is call a single propertyWasSet() function when any property within a C# class is set (conversely, propertyWasGot() when it is get). I would also like to know which property's 'get' was invoked.
I would like to maintain a dictonary of properties that are 'set', and check upon the 'get' action if they have been set yet (and throw an error if it hasn't been).
I've be looking through msdn documentation for reflection, delegates, etc…, but I'm not entirely sure this is possible.
Is there a way to do this? or fire an event upon calling one of these functions that can be intercepted in a base class or something?
Best Solution
I wrote an interceptor the other week for Set which can easily be extended for Get, it uses RealProxy, which means your base class needs to derive off MarshalByRefObject.
Another fancy option is to have your class abstract, and use Reflection Emit to construct a concrete class that wraps up all the properties.
Also you could look at code generators to get around this or PostSharp...
Performance for this solution is not stellar, but it should be plenty fast for most UI binding. It could be improved by generating LCG methods for proxy invocation.
Usage: