ShiftOS_TheReturn/ShiftOS.Objects/UserConfig.cs

41 lines
1.1 KiB
C#
Raw Normal View History

2017-05-21 12:21:41 +00:00
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
namespace ShiftOS.Objects
{
public class UserConfig
{
2017-06-19 14:18:55 +00:00
public string Language { get; set; }
2017-05-21 12:21:41 +00:00
public string DigitalSocietyAddress { get; set; }
public int DigitalSocietyPort { get; set; }
private static UserConfig def = new UserConfig
2017-05-21 12:21:41 +00:00
{
2017-06-19 14:18:55 +00:00
Language = "english",
2017-05-21 12:21:41 +00:00
DigitalSocietyAddress = "michaeltheshifter.me",
DigitalSocietyPort = 13370
};
public static UserConfig current = null;
public static UserConfig Get()
{
if (current != null)
return current;
if (File.Exists("servers.json"))
current = JsonConvert.DeserializeObject<UserConfig>(File.ReadAllText("servers.json"));
2017-05-21 12:21:41 +00:00
else
{
File.WriteAllText("servers.json", JsonConvert.SerializeObject(def, Formatting.Indented));
current = def;
2017-05-21 12:21:41 +00:00
}
return current;
2017-05-21 12:21:41 +00:00
}
}
}