For a single domain model, can I serialize to and deserialize from multiple schema's?

Jul 8, 2014 at 11:25 AM
Edited Jul 15, 2014 at 5:43 AM
The reason for this question is because I am building a Windows App. This App will have to compose a webservice request with data which comes from the following locations:
  • other domain objects (in memory)
  • local storage (stored as JSON)
  • device settings (stored as JSON)
  • roaming settings (stored as JSON)
What I would like to do is build a single domain model and then:
  1. partial fill it with data from all above mentioned locations (deserialize JSON to domain object, copy from in memory objects)
  2. allow the user to modify the settings in the GUI
  3. add process output
  4. send a subset of the domain model to the webservice (this subset is a collection of several properties from all sets)
  5. save another subset of the domain model back to the roaming settings
  6. save yet another subset of the domain model back to the device settings
  7. save yet another subset of the domain model to local storage
I already saw it is possible to fill an existing model, so the partial filling should work.

The part I am unsure about is if and how I can specify which property will be serialized in which scenario. I would like to be able to make use of attributes saying a Property will be serialized to DeviceSettings or RoamingSettings or to the webservice or to all for that matter.

Can this be done with the current state of the code?