Load备份方法
public class BaseSettings
{
private Dictionary<string, int> intValues = null;
private Dictionary<string, string> strValues = null;
private Dictionary<string, bool> boolValues = null;
private Dictionary<string, double> doubleValues = null;
private DataSet ds = null;
public static bool TipEnable = true;
private const string intTableName = "IntTable";
private const string stringTableName = "StringTable";
private const string boolTableName = "BoolTable";
private const string doubleTableName = "DoubleTable";
private const string firstFieldName = "ParaName";
private const string secondFieldName = "ParaValue";
public string Name {
get; private set; }
private string SettingFileName
{
get
{
string asmFile = this.GetType().Assembly.Location;
string asmPath = Path.GetDirectoryName(asmFile);
if (string.Compare(Name, "Settings") == 0)
{
return Path.ChangeExtension(asmFile, ".xml");
}
else
{
return Path.Combine(asmPath, string.Format("{0}.xml", Name));
}
}
}
public BaseSettings(string settingName)
{
intValues = new Dictionary<string, int>();
strValues = new Dictionary<string, string>();
boolValues = new Dictionary<string, bool>();
doubleValues = new Dictionary<string, double>();
Name = settingName;
SetupDataset();
this.Load();
}
private void SetupDataset()
{
ds = new DataSet(Name);
DataTable tbInt = new DataTable(intTableName);
tbInt.Columns.Add(new DataColumn(firstFieldName, typeof(string)));
tbInt.Columns.Add(new DataColumn(secondFieldName, typeof(int)));
ds.Tables.Add(tbInt);
DataTable tbString = new DataTable(stringTableName