I wish to know what the best way is to create Saving and Loading logic so that I can save and load x items. For example, in Isolated Storage I can easily save a composite/POCO object by doing this:
var settings = IsolatedStorageSettings.ApplicationSettings;
settings.Add("key", myObject);
And load like this:
var settings = IsolatedStorageSettings.ApplicationSettings;
return settings["key"] as MyObject;
But how would I load x amount of Objects from IsolatedStorage? Would it be best to create a List<MyObject>
collection and save and whenever I want to save another object I basically load the existing and do .Add(newObject)
and save again?
So something like this:
List<MyObject> myObjects = new List<MyObject>();
myObjects.Add(newObject);
settings.Add("myObjects", myObjects);
and when Loading:
var myObjects = settings["myObjects"] as List<MyObject>;
This would however require deleting and adding the collection back in as settings.Add
requires a unique key. Would this be the best way?
I'd much rather use settings than a Iso File.
See Question&Answers more detail:os