StableVersion4.3/AppAutoUpdater/AutoUpdater/AutoUpdateHelper/Config.cs

71 lines
1.9 KiB
C#

/*****************************************************************
* Copyright (C) Knights Warrior Corporation. All rights reserved.
*
* Author: Ê¥µîÆïÊ¿£¨Knights Warrior£©
* Email: KnightsWarrior@msn.com
* Website: http://www.cnblogs.com/KnightsWarrior/ https://github.com/knightswarrior
* Create Date: 5/8/2010
* Usage:
*
* RevisionHistory
* Date Author Description
*
*****************************************************************/
using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
using System.Xml.Serialization;
using System.IO;
namespace KnightsWarriorAutoupdater
{
public class Config
{
#region The private fields
private bool enabled = true;
private string serverUrl = string.Empty;
private UpdateFileList updateFileList = new UpdateFileList();
#endregion
#region The public property
public bool Enabled
{
get { return enabled; }
set { enabled = value; }
}
public string ServerUrl
{
get { return serverUrl; }
set { serverUrl = value; }
}
public UpdateFileList UpdateFileList
{
get { return updateFileList; }
set { updateFileList = value; }
}
#endregion
#region The public method
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();
}
#endregion
}
}