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