I have a WPF client application receiving objects via a reference to a remote WCF service. The WCF service references were generated via Visual Studio’s ‘Add Service Reference…’.
I would like to execute a piece of code each time an object received/deserialized from the WCF service. The object needs to already be deserialized so I can read properties/call methods on it. This solution would be global and not something I need to add to every WCF service call.
Starting with Mike’s initial response I was able to come up with the following solution.
Background
Forewarning
I understand that this breaks some object oriented and responsibility rules, however the solution is so short, so easy, and fits my current and anticipated future needs so it is what I went with. This solution is less practical when there is significant logic that needs to occur on each client-side deserialization.
The keys
dynamic keyword because the project containing the DTO cannot reference the
UI project due to a circular reference. If it can’t reference the UI project the compiler does not know about the IsAnythingDirty boolean.