/// <summary> /// Met à jour la liste des films d'une personne /// </summary> /// <param name="pers">La personne</param> /// <param name="film">Le film a ajouter</param> public override Personne mettreAJourListeFilmsDeLaPersonne(Personne pers, Film film) { pers.listeFilms.Add(film); using (var isolatedStorage = IsolatedStorageFile.GetUserStoreForApplication()) { using (IsolatedStorageFileStream isolatedStorageFileStream = isolatedStorage.OpenFile(XMLTags.FICHIER_PERSONNES, System.IO.FileMode.Open)) { System.Xml.XmlWriterSettings settings = new System.Xml.XmlWriterSettings(); settings.Indent = true; using (System.Xml.XmlWriter writer = System.Xml.XmlWriter.Create(isolatedStorageFileStream, settings)) { PersonneWriter writerPersonne = new PersonneWriterWP7(); writerPersonne.mXDoc = new XDocument(); writerPersonne.mXDoc.Add(new XElement(XMLTags.PERSONNES)); foreach (Personne g in listePersonnes) { writerPersonne.saveData(g, null); } writerPersonne.UpdateListeFilmsPersonne(pers, film, null); writerPersonne.mXDoc.Save(writer); } } } return(pers); }
/// <summary> /// Réécris le fichier personnes.xml /// </summary> public override void writePersonnes() { ListePersonne liste = new ListePersonne(); liste.InitialiseListePersonne(); PersonneWriter writer = new PersonneWriterWP7(); writer.WritePersonnes(liste.listePersonne); writer.Save(XMLTags.FICHIER_PERSONNES); }
/// <summary> /// sauvegarde les personnes en chambre d'isolation /// </summary> /// <param name="isolatedStorage"></param> private void savePersonnes(IsolatedStorageFile isolatedStorage) { using (var isolatedStorageFileStream = isolatedStorage.OpenFile(XMLTags.FICHIER_PERSONNES, System.IO.FileMode.Create)) { System.Xml.XmlWriterSettings settings = new System.Xml.XmlWriterSettings(); settings.Indent = true; using (System.Xml.XmlWriter writer = System.Xml.XmlWriter.Create(isolatedStorageFileStream, settings)) { PersonneWriter writerPersonne = new PersonneWriterWP7(); writerPersonne.mXDoc = new XDocument(); writerPersonne.mXDoc.Add(new XElement(XMLTags.PERSONNES)); foreach (Personne p in listePersonnes) { writerPersonne.saveData(p, null); } writerPersonne.mXDoc.Save(writer); } } }