基线 SVN r240
SVN-Revision: r240
This commit is contained in:
@@ -0,0 +1,87 @@
|
||||
/******************************
|
||||
* 说明:自动升级配置文件
|
||||
* 创建人:龚宇超
|
||||
* 创建日期:2018-02-09
|
||||
* 修改人:
|
||||
* 修改日期:
|
||||
* 修改备注:
|
||||
* 版本:1.0.0.0
|
||||
******************************/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Xml;
|
||||
using System.Xml.Serialization;
|
||||
using System.IO;
|
||||
|
||||
namespace Lskj.AutoUpdate
|
||||
{
|
||||
/// <summary>
|
||||
/// 自动升级配置文件
|
||||
/// </summary>
|
||||
public class Config
|
||||
{
|
||||
private string _serverUrl = string.Empty;
|
||||
private UpdateFileList _updateFileList = new UpdateFileList();
|
||||
|
||||
/// <summary>
|
||||
/// 下载地址
|
||||
/// </summary>
|
||||
/// <value>The server URL.</value>
|
||||
public string ServerUrl
|
||||
{
|
||||
get { return _serverUrl; }
|
||||
set { _serverUrl = value; }
|
||||
}
|
||||
/// <summary>
|
||||
/// 下载文件地址
|
||||
/// </summary>
|
||||
/// <value>The update file list.</value>
|
||||
public UpdateFileList UpdateFileList
|
||||
{
|
||||
get { return _updateFileList; }
|
||||
set { _updateFileList = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <para>说明:加载配置</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
/// <para>创建日期:2018-02-23 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
/// <param name="file">The file.</param>
|
||||
/// <returns>Config.</returns>
|
||||
public Config LoadConfig(string file)
|
||||
{
|
||||
if (!File.Exists(file)) SaveConfig(file);
|
||||
|
||||
XmlSerializer xs = new XmlSerializer(typeof(Config));
|
||||
StreamReader sr = new StreamReader(file);
|
||||
Config config = xs.Deserialize(sr) as Config;
|
||||
sr.Close();
|
||||
|
||||
return config;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <para>说明:保存配置</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
/// <para>创建日期:2018-02-23 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
/// <param name="file">The file.</param>
|
||||
public void SaveConfig(string file)
|
||||
{
|
||||
XmlSerializer xs = new XmlSerializer(typeof(Config));
|
||||
StreamWriter sw = new StreamWriter(file);
|
||||
xs.Serialize(sw, this);
|
||||
sw.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user