using GummingCommon; using System.IO; using System.Xml.Serialization; namespace GummingCommon { public class SystemInfoService { public SystemSettingInfo Systems { get; private set; } static SystemInfoService _instance; static object _lockFlg = new object(); public static SystemInfoService Instance() { if (_instance == null) { lock (_lockFlg) { if (_instance == null) { _instance = new SystemInfoService(); } } } return _instance; } private SystemInfoService() { Systems = new SystemSettingInfo(); } public void Save() { if (!Directory.Exists(SystemConst.SystemFolder)) { Directory.CreateDirectory(SystemConst.SystemFolder); } XmlSerializer serializer = new XmlSerializer(typeof(SystemSettingInfo)); using (FileStream fs = new FileStream(SystemConst.SystemFile, FileMode.Create)) { //Systems.ConnectionPassWord = Encryption.Encrypt(Systems.ConnectionPassWord); serializer.Serialize(fs, Systems); //Systems.ConnectionPassWord = Encryption.Decrypt(Systems.ConnectionPassWord); } } public void Load() { if (File.Exists(SystemConst.SystemFile)) { XmlSerializer serializer = new XmlSerializer(typeof(SystemSettingInfo)); using (FileStream fs = new FileStream(SystemConst.SystemFile, FileMode.Open)) { object obj = serializer.Deserialize(fs); if (obj != null) { Systems = (SystemSettingInfo)obj; try { //Systems.ConnectionPassWord = Encryption.Decrypt(Systems.ConnectionPassWord); } catch { } } } } } } }