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