9

Closed

[Phone] Tombstoning Doesn't Support Composite View Models

description

The scenario in question is that in a WP7 app, a view model (a Conductor for example) has an Items collection, which may contain other view models. The user can add new items on the fly, and therefore we don't have specific design-time knowledge of them. However, we want to be able to persist them using CM's tombstoning support.

We should be able to, in the storage handler for the conductor, specify that the Items property (or any other collection) should get persisted. Ideally, the storage mechanism should then look up any available storage handlers for the view model types contained in Items (or other specified collections) in order to persist them.

Currently, the storage mechanism simply attempts to serialize the objects in the collection in their entirety, which typically results in an exception. I've worked around this in my app using a custom implementation of IStorageHandler that does its own binary serialization; but I'd rather use the same mechanism for everything.

file attachments

Closed Feb 20 at 4:47 PM by EisenbergEffect
Moved to github.

comments

wpcfan wrote Aug 22, 2011 at 2:42 AM

Yes, I met with same problem, and I am now using WP7Contrib's caching library, find it is very good, can we consider providing a way to integrate 3rd-party cache library?

EisenbergEffect wrote Dec 31, 2012 at 1:31 PM

I'm open to any architecture recommendations that you think would make this more pluggable.

tibel wrote Jan 2, 2013 at 9:49 AM

I think the problem is how to register the view models in the Items collection of a conductor to the StorageHandler.

For save:
  • store Id (key) of Items
For restore:
  • use container to create Item instance (so the Item-StorageHandler can handle them)
  • set Id on Item and add to Items collection