I used the isolated storage before to save text files, xml files and images. However, is it possible to save variables of type IEnumerable using IsolatedStorage or any other resource in windows phone 7??
Thanks,
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You are misunderstanding core concepts.. There is no such thing as “saving variables”, you save objects. Your variable points to an object, and that objects implements IEnumerable. Is On WP7, it is the object’s actual class that determines whether that object can be serialized and stored on the ISO directly. If that actual collection class does not support serialization, you will have to re-wrap all its current elements into a List/Array/Dictionary/Stack/Queue – literally whatever what supports being serialized – and store that instead of.
Once you have an serializable collection, then your code for saving gets reduced to something as trivial as:
and in general, that’s it. Retrieving is similar:
where SomeCollection may be an IEnumerable, a List/Array/Dictionary/Stack/Queue – whatever you had put there and whatever is implemented by the actual collection class.
If you want, you may use IsolatedStorageFile and write files directly, but unless you have a good reason to – there’s no point in it, as using the common dictionary is far simplier.
In my other post you’ll find some links:
How to do isolated storage in Wp7?