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