zoukankan      html  css  js  c++  java
  • 关于Silverlight IsolatedStorage 不能Serialze Parameter[]

    手上项目需要保存 DomianDataSource的QueryName和Parameters, 当客户按F5后,读出这两个参数,加载数据。

    解决办法:

              是应用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;
            }

  • 相关阅读:
    通过vue-cli命令行安装uni-app
    微信小程序中父子通信
    react启动问题
    react 父子通信
    windows下MongoDB的安装和启动服务--转载
    vue中使用骨架 vue-skeleton-webpack-plugin
    像企业一样思考
    Promise原理详解
    如何封装一个Cookie库
    你应该知道的浏览器缓存知识
  • 原文地址:https://www.cnblogs.com/mjgb/p/1892082.html
Copyright © 2011-2022 走看看