aboutsummaryrefslogtreecommitdiff
path: root/ShiftOS.Objects
diff options
context:
space:
mode:
authorMichael <[email protected]>2017-06-25 13:46:39 -0400
committerMichael <[email protected]>2017-06-25 13:46:39 -0400
commit5bebd4411bc6266cbee482a429ba794eefa8f9b6 (patch)
treea68282dda40c4f0b28883241c7adcf9010f4550e /ShiftOS.Objects
parent8e19c8599975685410d7508b150f811dc3991f4a (diff)
parent6f5e69bd9df3bd44c098a179458fd37ca6114685 (diff)
downloadshiftos_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.cs21
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;
}
}
}