public void SetNewBiography(Biography biography)
 {
     if (biography != null)
     {
         Bio = biography;
     }
     else
     {
         Console.WriteLine($" Biography do not contain information about person (referense is NULL)!");
     }
 }
        private void SerialiseBiography(Biography bio)
        {
            string path = "E://samples/Biography/biography.txt";

            using (StreamWriter sw = new StreamWriter(path, false))
            {
                string jsonBiography = JsonSerializer.Serialize <Biography>(bio);

                sw.Write(jsonBiography);
                Console.WriteLine($"The object serialized to file {path}.\n");
            }
        }
        private Biography DeserializeBiography()
        {
            Biography biography = null;

            try
            {
                using (StreamReader sr = new StreamReader(pathToFile))
                {
                    string jsonBiography = sr.ReadToEnd();
                    biography = JsonSerializer.Deserialize <Biography>(jsonBiography);
                    Console.WriteLine($"The object deserialized from the file {pathToFile}.\n");
                }
                return(biography);
            }
            catch (Exception ex)
            {
                Console.WriteLine($" Exception in DeserializeBiography(): {ex.Message}\n" +
                                  $" Method will return NULL!!!");
                return(biography);
            }
        }
 public void SerializeOrDeserializeBio(Biography bio, Mode mode)
 {
     try
     {
         if (bio == null && mode.ToString() == "Serialize")
         {
         }
         if (mode.ToString() == "Serialize")
         {
             SerialiseBiography(bio);
             return;
         }
         if (mode.ToString() == "Deserialize")
         {
             Bio = DeserializeBiography();
             return;
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine($" Error!!! : {ex.Message}");
     }
 }
 public Person(Biography bio)
 {
     Bio = bio;
 }