diff options
| author | Michael <[email protected]> | 2017-06-25 13:46:39 -0400 |
|---|---|---|
| committer | Michael <[email protected]> | 2017-06-25 13:46:39 -0400 |
| commit | 5bebd4411bc6266cbee482a429ba794eefa8f9b6 (patch) | |
| tree | a68282dda40c4f0b28883241c7adcf9010f4550e /ShiftOS.Objects | |
| parent | 8e19c8599975685410d7508b150f811dc3991f4a (diff) | |
| parent | 6f5e69bd9df3bd44c098a179458fd37ca6114685 (diff) | |
| download | shiftos_thereturn-5bebd4411bc6266cbee482a429ba794eefa8f9b6.tar.gz shiftos_thereturn-5bebd4411bc6266cbee482a429ba794eefa8f9b6.tar.bz2 shiftos_thereturn-5bebd4411bc6266cbee482a429ba794eefa8f9b6.zip | |
Merge remote-tracking branch 'origin/master'
# Conflicts:
# ShiftOS.WinForms/ShiftOS.WinForms.csproj
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; } } } |
