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;
            }

  • 相关阅读:
    PSR-2 编码风格规范
    Git中删除冗余的分支
    linux下ssh连接缓慢详解
    pytest框架之fixture详细使用
    如何利用jenkins插件查看allure报告-----完整篇
    CentOS上安装配置Python3.7
    [Python]requests使用代理
    Selenium
    Python性能分析工具-cProfile
    subprocessf运行window程序
  • 原文地址:https://www.cnblogs.com/mjgb/p/1892082.html
Copyright © 2011-2022 走看看