I want a class (called PremiseServer) in my Mvvm-Light solution (WP7) to subscribe to all property changes for classes that are derived from a base type (SysObject is the base class and it derives from ViewModel).
I have a set of classes derived from SysObject. These classes have various properties on them of differing types (Strings, booleans, ints etc...).
When any property on any of these classes changes I want my PremiseServer instance to see these changes and then make web-service calls to push the data to a server.
I have tried this and it never gets called (which makes sense to me now; because the property that is getting changed is not SysObject, but some property OF the SysObject):
Messenger.Default.Register<PropertyChangedMessage<SysObject>>(this, (action) => {
String location = ((SysObject)action.Sender).Location; // URL to POST to
Debug.WriteLine("PremiseServer PropertyChange - " + action.NewValue.ToString());
});
I also tried the below (registering String messages) and it works, but I don't want to create one of these for each property type:
Messenger.Default.Register<PropertyChangedMessage<String>>(this, (action) => {
String location = ((SysObject)action.Sender).Location; // URL to POST to
Debug.WriteLine("PremiseServer PropertyChange - " + action.NewValue.ToString());
});
I also tried Register<PropertyChangeMessage<Object>
thinking I'd see messages for all derived types (I didn't).
What I really want is "Register for all property change messags from any property of objects of class SysObject". How can I do that?
Thanks!