using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Serialization;
using System.Text;
using System.IO;
using System.Xml;
namespace FutureDBDecompositionTools.Config
{
[Serializable]
public class Setting
{
static readonly string xmlFileName = AppDomain.CurrentDomain.BaseDirectory + "DecompositionSetting.xml";
static private Setting setting ;
public static Setting SettingInstance
{
get {
if (setting == null)
{
GetSettingFromXmlFile();
if (setting == null)
{
setting = new Setting();
}
}
return setting;
}
set {
setting = value;
}
}
private static void GetSettingFromXmlFile()
{
FileInfo file = new FileInfo(xmlFileName);
if (File.Exists(file.ToString()))
{
string xml = File.ReadAllText(file.FullName);
if ((xml!=null) && (xml != string.Empty))
{
setting = Logic.SimpleSerializer.Deserialize(typeof(Setting), xml) as
Setting;
}
}
}
public void SaveSettingToXmlFile()
{
string xml = Logic.SimpleSerializer.Serialize<Setting>(setting);
FileInfo file = new FileInfo(xmlFileName);
if (File.Exists(file.ToString()))
{
file.Delete();
}
File.WriteAllText(AppDomain.CurrentDomain.BaseDirectory + "DecompositionSetting.xml", xml);
}
private Setting() { }
private string matters_Offline;
[XmlElement("Matters_Offline")]
public string Matters_Offline
{
get
{
return matters_Offline;
}
set
{
matters_Offline = value;
}
}
string orderDatas_Offline;
[XmlElement("OrderDatas_Offline")]
public string OrderDatas_Offline
{
get
{
return orderDatas_Offline;
}
set
{
orderDatas_Offline = value;
}
}
string distributes_Offline;
[XmlElement("Distributes_Offline")]
public string Distributes_Offline
{
get
{
return distributes_Offline;
}
set
{
distributes_Offline = value;
}
}
string jobs_Offline;
[XmlElement("Jobs_Offline")]
public string Jobs_Offline
{
get
{
return jobs_Offline;
}
set
{
jobs_Offline = value;
}
}
string parentDatas_Offline;
[XmlElement("ParentDatas_Offline")]
public string ParentDatas_Offline
{
get
{
return parentDatas_Offline;
}
set
{
parentDatas_Offline = value;
}
}
string childDatas_Offline;
[XmlElement("ChildDatas_Offline")]
public string ChildDatas_Offline
{
get
{
return childDatas_Offline;
}
set
{
childDatas_Offline = value;
}
}
string futureManagement_Offline;
[XmlElement("FutureManagement_Offline")]
public string FutureManagement_Offline
{
get
{
return futureManagement_Offline;
}
set
{
futureManagement_Offline = value;
}
}
string decompositionOrders_Offline;
[XmlElement("DecompositionOrders_Offline")]
public string DecompositionOrders_Offline
{
get
{
return decompositionOrders_Offline;
}
set
{
decompositionOrders_Offline = value;
}
}
string offline;
[XmlElement("Offline")]
[System.Configuration.DefaultSettingValueAttribute("False")]
public string Offline
{
get
{
return offline;
}
set
{
offline = value;
}
}
string dBAddress_Online;
[XmlElement("DBAddress_Online")]
public string DBAddress_Online
{
get
{
return dBAddress_Online;
}
set
{
dBAddress_Online = value;
}
}
string ddAddress_Offline;
[XmlElement("DBAddress_Offline")]
[System.Configuration.DefaultSettingValueAttribute("")]
public string DBAddress_Offline
{
get
{
return ddAddress_Offline;
}
set
{
ddAddress_Offline = value;
}
}
string accounts_Offline;
[XmlElement("Accounts_Offline")]
public string Accounts_Offline
{
get
{
return accounts_Offline;
}
set
{
accounts_Offline = value;
}
}
string dBAddress_Decomposition;
[XmlElement("DBAddress_Decomposition")]
public string DBAddress_Decomposition
{
get
{
return dBAddress_Decomposition;
}
set
{
dBAddress_Decomposition = value;
}
}
string decompositionOrders_Online;
[XmlElement("DecompositionOrders_Online")]
public string DecompositionOrders_Online
{
get
{
return decompositionOrders_Online;
}
set
{
decompositionOrders_Online = value;
}
}
public string this[string propertyName]
{
get
{
return (GetProperty(propertyName));
}
set
{
SetProperty(propertyName,value);
}
}
void SetProperty(string propertyName,string Value)
{
switch (propertyName)
{
case "Matters_Offline":
setting.Matters_Offline = Value;
break;
case "OrderDatas_Offline":
setting.OrderDatas_Offline = Value;
break;
case "Distributes_Offline":
setting.Distributes_Offline = Value;
break;
case "Jobs_Offline":
setting.Jobs_Offline = Value;
break;
case "ParentDatas_Offline":
setting.ParentDatas_Offline = Value;
break;
case "ChildDatas_Offline":
setting.ChildDatas_Offline = Value;
break;
case "FutureManagement_Offline":
setting.FutureManagement_Offline = Value;
break;
case "DecompositionOrders_Offline":
setting.DecompositionOrders_Offline = Value;
break;
case "Offline":
setting.Offline = Value;
break;
case "DBAddress_Online":
setting.DBAddress_Online = Value;
break;
case "DBAddress_Offline":
setting.DBAddress_Offline = Value;
break;
case "Accounts_Offline":
setting.Accounts_Offline = Value;
break;
case "DBAddress_Decomposition":
setting.DBAddress_Decomposition = Value;
break;
case "DecompositionOrders_Online":
setting.DecompositionOrders_Online = Value;
break;
default:
break;
}
}
string GetProperty(string propertyName)
{
string Value = string.Empty;
switch (propertyName)
{
case "Matters_Offline":
Value = setting.Matters_Offline;
break;
case "OrderDatas_Offline":
Value = setting.OrderDatas_Offline;
break;
case "Distributes_Offline":
Value = setting.Distributes_Offline;
break;
case "Jobs_Offline":
Value = setting.Jobs_Offline;
break;
case "ParentDatas_Offline":
Value = setting.ParentDatas_Offline;
break;
case "ChildDatas_Offline":
Value = setting.ChildDatas_Offline;
break;
case "FutureManagement_Offline":
Value = setting.FutureManagement_Offline;
break;
case "DecompositionOrders_Offline":
Value = setting.DecompositionOrders_Offline;
break;
case "Offline":
Value = setting.Offline;
break;
case "DBAddress_Online":
Value = setting.DBAddress_Online;
break;
case "DBAddress_Offline":
Value = setting.DBAddress_Offline;
break;
case "Accounts_Offline":
Value = setting.Accounts_Offline;
break;
case "DBAddress_Decomposition":
Value = setting.DBAddress_Decomposition;
break;
case "DecompositionOrders_Online":
Value = setting.DecompositionOrders_Online;
break;
default:
break;
}
return Value;
}
}
}