private void ParseHelpItems() { string lang = m_XmlReader.GetAttribute("id"); while (m_XmlReader.Read()) { if (m_XmlReader.IsStartElement()) { if (m_XmlReader.Name == "manual") { HelpItem hi = ParseHelpItem(lang, m_XmlReader.Name); UserGuides.Add(hi); } if (m_XmlReader.Name == "video") { HelpItem hi = ParseHelpItem(lang, m_XmlReader.Name); HelpVideos.Add(hi); } } else if (m_XmlReader.Name == "lang") { break; } else { // Fermeture d'un tag interne. } } }
private void UpdateHelpItem(HelpItem _hiLocalCopy, HelpItem _hiUpdatedCopy, string _szFolder) { // rempli plus tard dynamiquement : _hiLocalCopy.Description _hiLocalCopy.FileLocation = _szFolder + "\\" + Path.GetFileName(_hiUpdatedCopy.FileLocation); _hiLocalCopy.FileSizeInBytes = _hiUpdatedCopy.FileSizeInBytes; _hiLocalCopy.Identification = _hiUpdatedCopy.Identification; _hiLocalCopy.Language = _hiUpdatedCopy.Language; _hiLocalCopy.LocalizedTitle = _hiUpdatedCopy.LocalizedTitle; _hiLocalCopy.Revision = _hiUpdatedCopy.Revision; _hiLocalCopy.Comment = _hiUpdatedCopy.Comment; }
public void UpdateIndex(HelpItem helpItem, int listId) { //----------------------------------------------------- // Vérifier s'il existe déjà, mettre à jour ou ajouter. //----------------------------------------------------- // 1. Choix de la liste. List <HelpItem> hiList; string szDownloadFolder = "";; if (listId == 0) { hiList = UserGuides; szDownloadFolder = Application.StartupPath + "\\" + Properties.Resources.ManualsFolder; } else { hiList = HelpVideos; szDownloadFolder = Application.StartupPath + "\\" + Properties.Resources.HelpVideosFolder; } // 2. Recherche de l'Item. bool found = false; int i = 0; while (!found && i < hiList.Count) { if (helpItem.Identification == hiList[i].Identification && helpItem.Language == hiList[i].Language) { found = true; // Mise à jour. UpdateHelpItem(hiList[i], helpItem, szDownloadFolder); } else { i++; } } if (!found) { // Ajout. HelpItem hiNew = new HelpItem(); UpdateHelpItem(hiNew, helpItem, szDownloadFolder); hiList.Add(hiNew); } }
private HelpItem ParseHelpItem(string lang, string tag) { HelpItem hi = new HelpItem(); hi.Identification = int.Parse(m_XmlReader.GetAttribute("id")); hi.Revision = int.Parse(m_XmlReader.GetAttribute("revision")); hi.Language = lang; while (m_XmlReader.Read()) { if (m_XmlReader.IsStartElement()) { if (m_XmlReader.Name == "title") { hi.LocalizedTitle = m_XmlReader.ReadString(); } if (m_XmlReader.Name == "filesize") { hi.FileSizeInBytes = int.Parse(m_XmlReader.ReadString()); } if (m_XmlReader.Name == "location") { hi.FileLocation = m_XmlReader.ReadString(); } if (m_XmlReader.Name == "comment") { hi.Comment = m_XmlReader.ReadString(); } } else if (m_XmlReader.Name == tag) { break; } else { // Fermeture d'un tag interne. } } return(hi); }