This GitHub Gist shows a method for automatically monitoring the data contents of a particular class instance. If the data changes the originally computed hash changes and is therefore deemed “dirty” in that it’s no longer in the same state when monitoring began. Object relational mapping (ORM) frameworks make extensive use of similar techniques to decide if database entities in memory require writing back to the database. This is a variation on this but much more lightweight and very easily controllable.

This functionality has been rolled into a Nuget you can get here.