public static void Reload() { try { if (!File.Exists(Methods.ProgramPaths.InternalSwitchesFilePath)) { File.Create(Methods.ProgramPaths.InternalSwitchesFilePath).Close(); } string json = File.ReadAllText(Methods.ProgramPaths.InternalSwitchesFilePath); try { JsonSerializerSettings settings = new JsonSerializerSettings(); settings.ObjectCreationHandling = ObjectCreationHandling.Replace; InternalSwitches result = JsonConvert.DeserializeObject <InternalSwitches>(json, settings); if (result != null) { DefaultInstance = result; } else { DefaultInstance = new InternalSwitches(); } } catch { DefaultInstance = new InternalSwitches(); } } catch (Exception ex) { Methods.ProgramBase.Log.ErrorFormat("Failed to Load InternalSwitches! Reason: {0}", ex.Message); Methods.ProgramBase.Log.InfoFormat("Creating a new InternalSwitches in Memory..."); DefaultInstance = new InternalSwitches(); } }
public static void Reset() { DefaultInstance = new InternalSwitches(); Save(); Reload(); }