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

  • 相关阅读:
    ubuntu下wget的配置文件在哪里
    ubuntu下apt-get的配置文件是哪个
    Jar包方式运行web项目
    深入浅说服务如何以Jar包的方式发布
    maven 私服的setting.xml配置
    maven 配置私服 连接
    一、Spring MVC起步——IntelliJ IDEA 搭建Spring MVC环境(手把手搭建)
    intellij IDEA配置tomcat
    maven工程项目与项目之间的依赖方式
    手动创建Maven项目并建立两个项目之间的依赖关系
  • 原文地址:https://www.cnblogs.com/mjgb/p/1892082.html
Copyright © 2011-2022 走看看