public static void Save(BindingList <VisaTask> tasks, VisaEntityType type) { string filemane = getFileName(type); using (FileStream fs = new FileStream(AssemblyDirectory + filemane, FileMode.Create)) { XmlSerializer xs = new XmlSerializer(typeof(BindingList <VisaTask>)); xs.Serialize(fs, tasks); } }
public static BindingList <VisaTask> DeSerialize(VisaEntityType type) { string filemane = getFileName(type); BindingList <VisaTask> tasks = new BindingList <VisaTask>(); if (File.Exists(AssemblyDirectory + filemane)) { using (FileStream fs = new FileStream(AssemblyDirectory + filemane, FileMode.Open)) { XmlSerializer xs = new XmlSerializer(typeof(BindingList <VisaTask>)); tasks = (BindingList <VisaTask>)xs.Deserialize(fs); } } return(tasks); }
private static string getFileName(VisaEntityType type) { return(type == VisaEntityType.New ? "\\data.xml" : "\\completedData.xml"); }