屠宰场客户端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

61 lines
1.2 KiB

using BO.Utils;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace BO.Utils
{
public class ButcherAppContext
{
private static string loginConfigPath = Application.StartupPath + "\\Config.xml";
public ServerUrlConfig UrlConfig
{
get;
set;
}
public LoginUserInfo UserConfig
{
get;
set;
}
public ButcherAppContext()
{
UrlConfig = new ServerUrlConfig();
UserConfig = new LoginUserInfo();
}
public static ButcherAppContext Context
{
get
{
if (_appContext == null)
_appContext = CreateAppContext();
return _appContext;
}
}
private static ButcherAppContext _appContext;
static ButcherAppContext CreateAppContext()
{
var config = new ButcherAppContext();
if (!File.Exists(loginConfigPath))
{
XmlUtil.SerializerObjToFile(config, loginConfigPath);
}
else
config = XmlUtil.DeserializeFromFile<ButcherAppContext>(loginConfigPath);
return config;
}
public void Save()
{
XmlUtil.SerializerObjToFile(_appContext, loginConfigPath);
}
}
}