public void JsonDeserialize() { string json = File.ReadAllText("D:\\OOP\\Lab_14\\Lab_14\\bin\\Debug\\json.json"); Textbook book = JsonConvert.DeserializeObject< Textbook>(json); Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("Объект десериализован"); Console.ResetColor(); Console.WriteLine(book.ToString()); }
public void BinDeserialize() { BinaryFormatter formatter = new BinaryFormatter(); using (FileStream file = new FileStream("bin.dat", FileMode.OpenOrCreate)) { Textbook Book = (Textbook)formatter.Deserialize(file); Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("Объект десериализован"); Console.ResetColor(); Console.WriteLine(Book.ToString()); } }
public void SoapDeserialize() { SoapFormatter formatter = new SoapFormatter(); using (FileStream file = new FileStream("soap.soap", FileMode.OpenOrCreate)) { List<Textbook> list = new List<Textbook>(); Textbook Book = new Textbook(); for (int i = 0; i < 4; i++) { list.Add((Textbook)formatter.Deserialize(file)); } Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("Объект десериализован"); Console.ResetColor(); Console.WriteLine(Book.ToString()); } }