public Egypt(string name, string path)
 {
     _time = new CreationInfo(DateTime.Now);
     Name  = name;
     FileSystemManager.CheckPathValidity(path);
     JsonReadFromFile(path);
 }
        public static object NewtonsoftDeserialize <T>(string path)
        {
            FileSystemManager.CheckPathValidity(path);
            var obj = JsonConvert.DeserializeObject <T>(File.ReadAllText(path));

            return(obj);
        }
        public static void BinSerialize(object obj, string path)
        {
            FileSystemManager.CheckPathValidity(path.Remove(path.LastIndexOf('\\')));
            var formatter = new BinaryFormatter();

            using var stream = new FileStream(path, FileMode.OpenOrCreate);
            formatter.Serialize(stream, obj);
            stream.Close();
        }
        public static object BinDeserialize(string path)
        {
            FileSystemManager.CheckPathValidity(path);
            using var openFileStream = File.OpenRead(path);
            var deserializer = new BinaryFormatter();
            var obj          = deserializer.Deserialize(openFileStream);

            openFileStream.Close();
            return(obj);
        }
        public static void JsonSerialize(object obj, string path)
        {
            FileSystemManager.CheckPathValidity(path.Remove(path.LastIndexOf('\\')));
            var options = new JsonSerializerOptions
            {
                WriteIndented = true
            };

            using var stream = File.CreateText(path);
            stream.Write(JsonSerializer.Serialize(obj, options));
            stream.Close();
        }
 public static void NewtonsoftSerialize(object obj, string path)
 {
     FileSystemManager.CheckPathValidity(path.Remove(path.LastIndexOf('\\')));
     File.WriteAllText(path, JsonConvert.SerializeObject(obj, Formatting.Indented));
 }