//Sorting, serialization, and deserialization the collection "planes" by Max Load parameter private void XML_Ser_DeSer_Click(object sender, EventArgs e) { //Sorting AviaModel.Sortby(); //Serialization the collection "planes" to XML file planes.dat Methods.XMLSerialization.XMLFileSerialization(); List <AviaModel> DeserializedPlanes = Methods.XMLSerialization.DeserializeFromXML(); //foreach (List<AviaModel> DeserializedPlanes in AviaModel.planes) //{ // str = str + "Make=" + Deserilizeairplanes.Make.ToString() + " Board Number=" + Deserilizeairplanes.BoardNum.ToString() + " Max Load=" + Deserilizeairplanes.MaxLoad.ToString() + "\n"; //}; //this.richTextBox1.Text = "Object 'planes' has been serialized and deserialized"+"\n"+str; //Deserialization the collection "planes" to file planes.dat //output to the Form //string str = ""; //foreach (AviaModel deserializaAviamodel in AviaModel.planes) //{ // str = str + "Make=" + deserializaAviamodel.Make.ToString() + " Board Number=" + deserializaAviamodel.BoardNum.ToString() + " Max Load=" + deserializaAviamodel.MaxLoad.ToString() + "\n"; //}; //this.richTextBox1.Text = "Object 'planes' has been serialized and deserialized"+"\n"+str; }
//Sorting, serialization, and deserialization the collection "planes" by Max Load parameter private void Sort_Click(object sender, EventArgs e) { //Sorting AviaModel.Sortby(); //Serialization the collection "planes" to file planes.dat BinaryFormatter formatter = new BinaryFormatter(); using (FileStream fs = new FileStream("../../planes.dat", FileMode.OpenOrCreate)) { formatter.Serialize(fs, AviaModel.planes); }; //Deserialization the collection "planes" to file planes.dat using (FileStream fs1 = new FileStream("../../planes.dat", FileMode.OpenOrCreate)) { List <AviaModel> deserializeAviamodel = (List <AviaModel>)formatter.Deserialize(fs1); }; //output to the Form string str = ""; foreach (AviaModel deserializaAviamodel in AviaModel.planes) { str = str + "Make=" + deserializaAviamodel.Make.ToString() + " Board Number=" + deserializaAviamodel.BoardNum.ToString() + " Max Load=" + deserializaAviamodel.MaxLoad.ToString() + "\n"; } ; this.richTextBox1.Text = "Object 'planes' has been serialized and deserialized" + "\n" + str; }
private void JSON_Ser_DeSer_Click(object sender, EventArgs e) { AviaModel.Sortby(); Methods.JSONSerealization jsonserial = new Methods.JSONSerealization(); jsonserial.JSONSerealiz("../../JSON.JSON"); this.richTextBox1.Text = "Object 'planes' has been serialized in JSON and deserialized" + "\n" + jsonserial.JSONDeserealiz("../../JSON.JSON").ToString(); // string str = ""; // foreach (AviaModel jsondeserializaAviamodel in (AviaModel)AM) //{ // str = str + "Make=" + jsondeserializaAviamodel.Make.ToString() + " Board Number=" + jsondeserializaAviamodel.BoardNum.ToString() + " Max Load=" + jsondeserializaAviamodel.MaxLoad.ToString() + "\n"; //}; this.richTextBox1.Text = "Object 'planes' has been serialized in JSON and deserialized" + "\n"; }