public ParkWindow() { God g1 = new God("Zevs", 342343467); God g2 = new God("Venera", 53453453); God g3 = new God("Upiter", 879798798); God g4 = new God("Aid", 353453); God g5 = new God("Appolon", 2342342); Olymp olymp = new Olymp(5); MyXmlSerializer XMLSer = new MyXmlSerializer(); olymp = XMLSer.xmlDeserialize(); data = olymp.gods; InitializeComponent(); dgGods.IsReadOnly = true; labelH.Visibility = Visibility.Hidden; labelK.Visibility = Visibility.Hidden; textH.Visibility = Visibility.Hidden; textK.Visibility = Visibility.Hidden; button_save.Visibility = Visibility.Hidden; button_save_edit.Visibility = Visibility.Hidden; dgGods.ItemsSource = data; }
public void BinarySerialize(Olymp olymp) { BinaryFormatter formatter = new BinaryFormatter(); using (FileStream fs = new FileStream("C:\\Users\\ASA\\Documents\\Visual Studio 2015\\Projects\\ConsoleApplication1\\ConsoleApplication1\\gods.dat", FileMode.OpenOrCreate)) { formatter.Serialize(fs, olymp); } }
public void xmlSerialize(Olymp olymp) { XmlSerializer formatter = new XmlSerializer(typeof(Olymp)); using (FileStream fs = new FileStream("C:\\Users\\ASA\\Documents\\Visual Studio 2015\\Projects\\ConsoleApplication1\\ConsoleApplication1\\gods.xml", FileMode.Create)) { formatter.Serialize(fs, olymp); } }
void Window_Closing(object sender, CancelEventArgs e) { Olymp olymp = new Olymp(); foreach (var item in data) { olymp.addGod(new God()); } MyXmlSerializer serialisator = new MyXmlSerializer(); serialisator.xmlSerialize(olymp); }
public Olymp BinaryDesserialize() { BinaryFormatter formatter = new BinaryFormatter(); using (FileStream fs = new FileStream("C:\\Users\\ASA\\Documents\\Visual Studio 2015\\Projects\\ConsoleApplication1\\ConsoleApplication1\\gods.dat", FileMode.OpenOrCreate)) { Olymp olymp = (Olymp)formatter.Deserialize(fs); foreach (God god in olymp.gods) { Console.WriteLine("name " + god.name + " " + "ancientAge " + god.ancientAge); } return(olymp); } }
public Olymp xmlDeserialize() { XmlSerializer formatter = new XmlSerializer(typeof(Olymp)); using (FileStream fs = new FileStream("C:\\Users\\ASA\\Documents\\Visual Studio 2015\\Projects\\ConsoleApplication1\\ConsoleApplication1\\gods.xml", FileMode.Open)) { Olymp newOlymp = (Olymp)formatter.Deserialize(fs); foreach (God god in newOlymp.gods) { Console.WriteLine("name " + god.name + " " + "ancientAge " + god.ancientAge); } return(newOlymp); } }