开发者

Storing a Dictionary<TKey, TValue> in isolated storage

I'm hitting a server and getting some data, am parsing this data and storing it in a Dictionary<TKey, TValue>.

I store this Dictionary<TKey, TValue> list in Isolated storage. Now, the problem is whenever am trying retrieve the Dictionary&开发者_StackOverflowlt;TKey, TValue> (in 2nd run) what ever I have stored in the 1st run, the values for each key in the bean would have become null. I dunno whether the way am storing the Dictionary<TKey, TValue> is wrong.

Code sample:

CacheManager.getInstance().PersistData(CacheManager.SERVICE_TABLE, 
    dictionaryList);

public void PersistData(string storageName, object dict)
{
    try
    {
        PersistDataStore.Add(storageName, dict);
        PersistDataStore.Save();
    }
    catch (Exception ex)
    {
    }
}


I got the solution to the problem, the members of the dictionary dict must be serialized. i.e.,

using System.Runtime.Serialization;
[DataContact]
public class classname()
{
[datamember]
public int propertyname;
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜