diff options
| author | RogueAI42 <[email protected]> | 2017-06-25 15:35:03 +1000 |
|---|---|---|
| committer | RogueAI42 <[email protected]> | 2017-06-25 15:35:03 +1000 |
| commit | 255ad0993d4334e306eb5475cee2cf82778dcecd (patch) | |
| tree | 7659b7ebd61167d8bf2c1c3d3df5fe366ec4010f /ShiftOS.Objects | |
| parent | 4c63e5e41c55d41c0bcaa09f125299d4b1892ef6 (diff) | |
| download | shiftos_thereturn-255ad0993d4334e306eb5475cee2cf82778dcecd.tar.gz shiftos_thereturn-255ad0993d4334e306eb5475cee2cf82778dcecd.tar.bz2 shiftos_thereturn-255ad0993d4334e306eb5475cee2cf82778dcecd.zip | |
refactoring a few server-related things
Diffstat (limited to 'ShiftOS.Objects')
| -rw-r--r-- | ShiftOS.Objects/UserConfig.cs | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/ShiftOS.Objects/UserConfig.cs b/ShiftOS.Objects/UserConfig.cs index 579ce00..8232230 100644 --- a/ShiftOS.Objects/UserConfig.cs +++ b/ShiftOS.Objects/UserConfig.cs @@ -14,24 +14,27 @@ namespace ShiftOS.Objects public string DigitalSocietyAddress { get; set; } public int DigitalSocietyPort { get; set; } - public static UserConfig Get() - { - var conf = new UserConfig + private static UserConfig def = new UserConfig { Language = "english", DigitalSocietyAddress = "michaeltheshifter.me", DigitalSocietyPort = 13370 }; - if (!File.Exists("servers.json")) - { - File.WriteAllText("servers.json", JsonConvert.SerializeObject(conf, Formatting.Indented)); - } + 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")); else { - conf = JsonConvert.DeserializeObject<UserConfig>(File.ReadAllText("servers.json")); + File.WriteAllText("servers.json", JsonConvert.SerializeObject(def, Formatting.Indented)); + current = def; } - return conf; + return current; } } } |
