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