예제 #1
0
        public void SetModel(AutoServiceModel autoServiceModel)
        {
            FileStream      fs        = new FileStream(Path, FileMode.Create);
            BinaryFormatter formatter = new BinaryFormatter();

            formatter.Serialize(fs, autoServiceModel);
            fs.Close();
        }
예제 #2
0
        public void SetModel(AutoServiceModel autoServiceModel)
        {
            XmlSerializer xmlSerializer = new XmlSerializer(typeof(AutoServiceModel));

            using (Stream writer = new FileStream(Path, FileMode.Create))
            {
                xmlSerializer.Serialize(writer, autoServiceModel);
            }
        }
예제 #3
0
        public AutoServiceModel GetModel()
        {
            XmlSerializer    xmlSerializer = new XmlSerializer(typeof(AutoServiceModel));
            AutoServiceModel result;

            try
            {
                using (Stream reader = new FileStream(Path, FileMode.OpenOrCreate))
                {
                    result = (AutoServiceModel)xmlSerializer.Deserialize(reader);
                    result.fileDataAccess = this;
                }
            }
            catch (Exception e)
            {
                result = new AutoServiceModel(this);
                SetModel(result);
            }
            return(result);
        }
예제 #4
0
        public AutoServiceModel GetModel()
        {
            FileStream       fs        = new FileStream(Path, FileMode.OpenOrCreate);
            BinaryFormatter  formatter = new BinaryFormatter();
            AutoServiceModel result;

            try
            {
                result = (AutoServiceModel)formatter.Deserialize(fs);
                fs.Close();
            }
            catch (Exception e)
            {
                fs.Close();
                result = new AutoServiceModel(this);
                SetModel(result);
            }

            return(result);
        }