/// <summary> /// Serializes objects to xml pickle library. /// </summary> /// <param name="PDI"></param> public static void createParcelXML(ParcelDictionaryItem PDI) { ///Creates folder for xml files if it doesn't exist. ///Add more features to check for existing and only overwrite if older than x days. DirectoryCreateChecks(Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "\\ParcelData\\"); ///Serializes the parcel dictionary object and all lists of key/values and tables contained within. XmlSerializer x = new XmlSerializer(typeof(ParcelDictionaryItem)); StreamWriter writer = new StreamWriter(XMLPath(PDI.ParcelId)); x.Serialize(writer, PDI); writer.Close(); writer = null; }
/// <summary> /// Deserializes a parcel dictionary from xml. For reference only. Functionality in Grasshopper plugin. /// </summary> /// <param name="path"></param> /// <returns></returns> public static ParcelDictionaryItem ParcelFromXML(string path) { while (IsFileLocked(new FileInfo(path))) { System.Threading.Thread.Sleep(TimeSpan.FromSeconds(.5)); } ParcelDictionaryItem PDI = new ParcelDictionaryItem(); XmlSerializer Xser = new XmlSerializer(typeof(ParcelDictionaryItem)); StreamReader reader = new StreamReader(path); PDI = (ParcelDictionaryItem)Xser.Deserialize(reader); reader.Close(); return PDI; }