/// <summary> /// Returns a list of SyncPairs retrieved from an XML file. /// </summary> /// <param name="p_syncPairDataFile"></param> /// <returns></returns> static List <SyncPair> LoadSyncPairs(string p_syncPairDataFile) { try { using (XmlReader xmlRdr = new XmlTextReader(p_syncPairDataFile)) { XmlSerializer x = new XmlSerializer(typeof(SyncPairRepository)); SyncPairRepository myRepo = (SyncPairRepository)x.Deserialize(xmlRdr); return(myRepo._syncPairs); } } catch (Exception e) { Console.WriteLine(e.Message); return(new List <SyncPair>()); } }
/// <summary> /// Returns true if writing SyncPairRepository is successful. /// </summary> /// <param name="syncPairRep"></param> /// <param name="p_syncPairDataFile"></param> /// <returns></returns> public static bool SaveSyncPairs(SyncPairRepository syncPairRep, string p_syncPairDataFile) { bool saveSuccessful = false; try { FileStream fstTargetFile = File.Create(p_syncPairDataFile); XmlSerializer xsrOutput = new XmlSerializer(syncPairRep.GetType()); xsrOutput.Serialize(fstTargetFile, syncPairRep); fstTargetFile.Close(); saveSuccessful = true; } catch (Exception e) { Console.Out.WriteLine(e.ToString()); } return(saveSuccessful); }