By definition INotifyPropertyChanged
interface deals with notification AFTER the value has changed and INotifyPropertyChanging
interface deals with notification BEFORE the value has changed. [NotifyPropertyChanged]
aspect implements both for you but does not provide a way to do what you want out of the box.
Further it postpones notifications until a more complex change on the same object, this both lowers number of notifications and makes sure that when notification occurs, the object is in correct state (think of a method changing several properties on the object) for the code that reacts to the notification (this does not apply to INotifyPropertyChanging
). More about the implementation details here.
You would need to implement an aspect that would implement your interface and would register itself for INotifyPropertyChanged
and INotifyPropertyChanging
, recording property values on each changing notification and using those recorded values on changed notification to raise your own event.
You would probably need to do the following:
It does not seem as a complex aspect but you would definitely need to familiarize yourself with advanced concepts of PostSharp's Aspect Framework.