文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>关于Silverlight IsolatedStorage 不能Serialze Parameter[]

关于Silverlight IsolatedStorage 不能Serialze Parameter[]

时间:2010-11-30  来源:mjg

解决办法:

          是应用IsolatedStorage将这两个参数保存到客户本地。

问题:使用下面代码

           IsolatedStorageSettings.ApplicationSettings["parameters"] =parameters;

根本就无法把parameters保存到本地。

解决办法:IsolatedStorageSettings 可以保存DictionaryEntry[]。简单添加两个扩展方法,转化一下就ok.

 public static DictionaryEntry[] ToDictionaryEntry(this Parameter[] parameters)
        {
            if (parameters == null || parameters.Length == 0)
                return null;
            DictionaryEntry[] result = new DictionaryEntry[parameters.Length];
            for (int i = 0; i < parameters.Length; i++)
            {
                DictionaryEntry de = new DictionaryEntry(parameters[i].ParameterName, parameters[i].Value);
                result[i] = de;
            }
            return result;
        }

 

        public static Parameter[] ToParameters(this DictionaryEntry[] des)
        {
            if (des == null || des.Length == 0)
                return null;
            Parameter[] result = new Parameter[des.Length];
            for (int i = 0; i < des.Length; i++)
            {
                Parameter p = new Parameter { ParameterName = des[i].Key.ToString(), Value = des[i].Value };
                result[i] = p;
            }
            return result;
        }

相关阅读 更多 +
排行榜 更多 +
夕鸟

夕鸟

生活实用 下载
partyplay

partyplay

聊天通讯 下载
婚礼纪

婚礼纪

生活实用 下载