/// <summary> /// load an xml file /// </summary> /// <param name="location"></param> /// <returns></returns> public PContents LoadPcontentsXml(String location, String userPath) { location = Path.Combine(userPath, location); PContents retrunObject = new PContents(); try { XmlSerializer ser = new XmlSerializer(typeof(PContents)); FileStream fs = new FileStream(Getpath(location), FileMode.Open); XmlReader reader = XmlReader.Create(fs); retrunObject = (PContents)ser.Deserialize(reader); fs.Close(); } catch (Exception e) { Console.WriteLine("" + e); } return (retrunObject); }
/// <summary> /// saves all given Products in a File "Products" at the given path and /// saves all PContents in contents at the specific Folder /// </summary> /// <param name="userPath"></param> /// <param name="inputProducts"></param> /// <param name="inputContents"></param> public void SaveModelsLocal(String userPath, List<Product> inputProducts, List<PContent> inputContents) { PContents savePcontents = new PContents(); savePcontents.listPContent = inputContents; Products saveProducts = new Products(); saveProducts.listProducts = inputProducts; DependencyService.Get<ISaveAndLoad>().SavePContentsXml(userPath, pContentLocation, savePcontents); DependencyService.Get<ISaveAndLoad>().SaveProductsXml(productLocation, saveProducts); }