在 WP7 上的孤立存储中存储大列表 [英] Storing a large list in isolatedStorage on WP7

查看:22
本文介绍了在 WP7 上的孤立存储中存储大列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Xml 序列化将一个包含大约 3,000 个对象的 List 存储在 Isolatedstorage 中.反序列化需要很长时间,我想知道您是否有任何建议可以加快速度.

I'm storing a List with around 3,000 objects in Isolatedstorage using Xml serialize. It takes too long to deserialize this and I was wondering if you have any recommendations to speed it up.

反序列化多达 500 个对象的时间是可以容忍的,但反序列化 3000 个对象需要很长时间.是否仅在模拟器上需要更长的时间,而在手机上会更快?

The time is tolerable to deserialize up to 500 objects, but takes forever to deserialize 3000. Does it take longer just on the emulator and will be faster on the phone?

我进行了大量搜索,有些文章说要使用二进制流阅读器,但我找不到.我是用二进制还是xml存储都无所谓,我只想把List持久化.

I did a whole bunch of searching and some article said to use a binary stream reader, but I can't find it. Whether I store in binary or xml doesn't matter, I just want to persist the List.

我暂时还不想看异步加载...

I don't want to look at asynchronous loading just yet...

推荐答案

查看作为sharpSerializer一部分的二进制序列化器:http://www.sharpserializer.com/en/index.html

Check out the binary serializer that is a part of sharpSerializer: http://www.sharpserializer.com/en/index.html

这很简单,而且效果很好.

It's very easy and works quite well.

这是一篇关于在 WP7 中使用它的博客:http://www.eugenedotnet.com/2010/12/windows-phone-7-serialization-sharpserializer/

Here's a blog that talks about using it in WP7: http://www.eugenedotnet.com/2010/12/windows-phone-7-serialization-sharpserializer/

我正在使用它(考虑这个伪代码,并使用 eugenedotnet 上列出的函数)

I am using it like (consider this psuedocode, and using the functions listed on eugenedotnet)

在 App.xaml.cs 中:

in App.xaml.cs:

Application_Dectivated()
{
     IsolatedStorageFileStream stream = store.OpenFile(fileName, FileMode.OpenOrCreate);
     Serialize(stream,(obj)MyHugeList<myObject>);
}

Application_Activated()
{
     IsolatedStorageFileStream stream = store.OpenFile(fileName, FileMode.Open);
     Deserialize(stream,(obj)MyHugeList<myObject>);
}

这篇关于在 WP7 上的孤立存储中存储大列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆