public void SetModel(AutoServiceModel autoServiceModel) { FileStream fs = new FileStream(Path, FileMode.Create); BinaryFormatter formatter = new BinaryFormatter(); formatter.Serialize(fs, autoServiceModel); fs.Close(); }
public void SetModel(AutoServiceModel autoServiceModel) { XmlSerializer xmlSerializer = new XmlSerializer(typeof(AutoServiceModel)); using (Stream writer = new FileStream(Path, FileMode.Create)) { xmlSerializer.Serialize(writer, autoServiceModel); } }
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); }
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); }