Quantcast
Channel: Json.NET
Viewing all articles
Browse latest Browse all 1767

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

$
0
0
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
  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 attribues saying a Property will be serialized to DeviceSettings or RoamingSettings or to the webservide or to all for that matter.

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

Viewing all articles
Browse latest Browse all 1767


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>