void ChangeSotr(Sotrudnik change) { Console.WriteLine("Enter the FIO"); change.FIO = Console.ReadLine(); Console.WriteLine("Enter the age"); change.Age = Console.Read(); Console.WriteLine("Enter the Department"); change.Department = Console.ReadLine(); Console.WriteLine("Enter the Position"); change.Position = Console.ReadLine(); SerializeS(change); }
public Sotrudnik newsSotrudni() { Sotrudnik newsotr = new Sotrudnik(); Console.WriteLine("Enter the FIO"); newsotr.FIO = Console.ReadLine(); Console.WriteLine("Enter the ID"); newsotr.ID = Int32.Parse(Console.ReadLine()); Console.WriteLine("Enter the age"); newsotr.Age = Int32.Parse(Console.ReadLine()); Console.WriteLine("Enter the Department"); newsotr.Department = Console.ReadLine(); Console.WriteLine("Enter the Position"); newsotr.Position = Console.ReadLine(); return(newsotr); }
public void DeserializeS(Sotrudnik sotrudnik) { try { XmlSerializer formatter = new XmlSerializer(typeof(Sotrudnik)); using (FileStream fs = new FileStream($"sotrudnik{ID}.xml", FileMode.OpenOrCreate)) { Sotrudnik ChangeSotrudnik = (Sotrudnik)formatter.Deserialize(fs); Console.WriteLine("Объект десериализован"); ChangeSotrudnik.PrintS(); ChangeSotr(ChangeSotrudnik); } } catch (Exception) { Console.WriteLine("Error Deserialization"); } }
public void SerializeS(Sotrudnik sotrudnik) { try { XmlSerializer formatter = new XmlSerializer(typeof(Sotrudnik)); using (FileStream fs = new FileStream($"Sotrudnik{ID}.xml", FileMode.OpenOrCreate)) { formatter.Serialize(fs, sotrudnik); Console.WriteLine("Объект сериализован"); } } catch (Exception) { Console.WriteLine("Error Serialization"); } }