コード例 #1
0
ファイル: Admin.cs プロジェクト: mirahajek/AnimalRegister
        /// <summary>
        /// Načtení dat o PRASNICE a Ostatní prasata
        /// </summary>
        private void LoadPigSaws()
        {
            XmlSerializer xml_pig = new XmlSerializer(Pigs.GetType());
            XmlSerializer xml_saw = new XmlSerializer(Saws.GetType());

            // Prasnice
            if (File.Exists(pathSaws))
            {
                using (StreamReader reader = new StreamReader(pathSaws))
                {
                    Saws = (List <Saw>)xml_saw.Deserialize(reader);
                }
            }
            else
            {
                Saws = new List <Saw>();
            }

            // Ostatní prasata
            if (File.Exists(pathPigs))
            {
                using (StreamReader reader = new StreamReader(pathPigs))
                {
                    Pigs = (List <Pig>)xml_pig.Deserialize(reader);
                }
            }
            else
            {
                Pigs = new List <Pig>();
            }
        }
コード例 #2
0
ファイル: Admin.cs プロジェクト: mirahajek/AnimalRegister
        /// <summary>
        /// Uložení prasat a prasnic na C- appData
        /// </summary>
        private void SavePigSaws()
        {
            // Serializéry pro prasata a prasnice
            XmlSerializer xml_pig = new XmlSerializer(Pigs.GetType());
            XmlSerializer xml_saw = new XmlSerializer(Saws.GetType());

            // Prasnice
            using (StreamWriter writter = new StreamWriter(pathSaws))
            {
                xml_saw.Serialize(writter, Saws);
            }
            // Ostatní
            using (StreamWriter writter = new StreamWriter(pathPigs))
            {
                xml_pig.Serialize(writter, Pigs);
            }
        }