Esempio n. 1
0
 public static void SaveJsonToFileRemoveOnNull <T>(this T data, string path, bool formatting = true)
     where T : class, IJsonSerializable
 {
     if (data == null)
     {
         FileWrapper.RemoveIfExists(path);
     }
     else
     {
         data.SaveToJsonFile(path, formatting);
     }
 }
Esempio n. 2
0
 public static bool LoadFromJsonFileIfExists <T>(string path, out T data, bool printError = true)
     where T : class, IJsonSerializable, new()
 {
     if (!FileWrapper.Exists(path))
     {
         data = default;
         return(false);
     }
     else
     {
         return(LoadFromJsonFile(path, out data, printError));
     }
 }
Esempio n. 3
0
 static FileStream OpenFileWrap(string path, FileMode mode, bool wrap)
 {
     return(wrap ? FileWrapper.Open(path, mode) : File.Open(path, mode));
 }