zoukankan      html  css  js  c++  java
  • 序列化和序列化的一个类

    代码
     public class Config
        {
            
    private bool enabled = true;
            
    public bool Enabled { get { return enabled; } set { enabled = value; } }

            
    private string serverUrl = "";
            
    public string ServerUrl { get { return serverUrl; } set { serverUrl = value; } }

            
    private UpdateFileList updateFileList = new UpdateFileList();
            
    public UpdateFileList UpdateFileList
            {
                
    get { return updateFileList; }
                
    set { updateFileList = value; }

             
            }

            
    public static Config LoadConfig(string file)
            {
                XmlSerializer xs 
    = new XmlSerializer(typeof(Config));
                StreamReader sr 
    = new StreamReader(file);
                Config config 
    = xs.Deserialize(sr) as Config;
                sr.Close();

                
    return config;
            }

            
    public void SaveConfig(string file)
            {
                XmlSerializer xs 
    = new XmlSerializer(typeof(Config));
                StreamWriter sw 
    = new StreamWriter(file);
                xs.Serialize(sw, 
    this);
                sw.Close();
            }
        }
  • 相关阅读:
    centos 卸载自带的apache
    静态方法绑定
    安装apc
    避免SSH连接因超时闲置断开
    svn使用安全问题
    接口类,和抽象类。
    function (规定参数必须为某个对象的实例)
    jquery 获取DIV边框的宽
    正则表达式(非捕获)
    Linux ftp服务器Proftp配置
  • 原文地址:https://www.cnblogs.com/johnwonder/p/1678344.html
Copyright © 2011-2022 走看看