示例#1
0
 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);
 }
示例#2
0
        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);
        }
示例#3
0
        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");
            }
        }
示例#4
0
        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");
            }
        }