Storing and Retrieving complex objects in Json using Windows 8.1 C#

Read below or skip right to the demo project, ignoring the terrible demo UI:

So far, 90% of the Windows 8 apps I’ve written require storing data for later, or reading data that was stored earlier. There’s a million different ways to do it, but I’ve had great success with and serialising / storing data this way. The only problem you have is when dealing with multiple types, and trying to figure out the best way to do it.

I’m not saying it’s the best way, but here’s what I’ve found that covers all of my requirements. I’ve condensed the class to make it easy for everyone to use, and you can even see it in action from the demo project.

This is the base abstract generic class called StorageBase, it will be responsible for all our heavy lifting.

What make this class awesome:

  • It deals with the get, getall, save and delete methods you’d expect with a storage system.
  • It requires the implementing class overrides the folder name property to split content into different folders of your Windows 8.1 app root.
  • It implements a constraint on the domain which looks like this…


The reason for that is due to how I name the files, no reason you couldn’t do it another way however.

Putting two and two together, this means that in order to manage multiple different object types as files, you can just create your domain model which inherits Identifiers, and a class which Inherits from StorageBase and call methods against it as per normal.

For example:

Hope this makes it easier to store complex objects in windows 8.1

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s