public static void loadGameListConfig(ListGames list) { XmlTextReader xr = null; int attributs_lus; Game tmpGame = null; try { xr = new XmlTextReader(GameXMLFile); while (xr.Read()) { if (xr.NodeType == XmlNodeType.Element && xr.Name == "Game") { tmpGame = new Game(); attributs_lus = 0; while (xr.Read()) { // Lecture des attributs d'une game if (xr.NodeType == XmlNodeType.Element && xr.Name == "Caption") { xr.Read(); tmpGame.Caption = xr.Value.Trim(); attributs_lus++; } else if (xr.NodeType == XmlNodeType.Element && xr.Name == "Twitch_ID") { xr.Read(); tmpGame.TwitchGameID = xr.Value.Trim(); attributs_lus++; } else if (xr.NodeType == XmlNodeType.Element && xr.Name == "Own3D_ID") { xr.Read(); tmpGame.Own3DGameID = xr.Value.Trim(); attributs_lus++; } // Sortie de while quand tous les attributs on été lu if (attributs_lus == 3) { list.add(tmpGame); break; } } } else if (xr.NodeType == XmlNodeType.Element && xr.Name == "DefaultGame") { xr.Read(); DefaultGame = xr.Value.Trim(); } } } catch (Exception ex) { throw ex; } finally { if (xr != null) xr.Close(); } }
public static void loadGameListConfig(ListGames list) { XmlTextReader xr = null; int attributs_lus; Game tmpGame = null; try { xr = new XmlTextReader(GameXMLFile); while (xr.Read()) { if (xr.NodeType == XmlNodeType.Element && xr.Name == "Game") { tmpGame = new Game(); attributs_lus = 0; while (xr.Read()) { // Lecture des attributs d'une game if (xr.NodeType == XmlNodeType.Element && xr.Name == "Caption") { xr.Read(); tmpGame.Caption = xr.Value.Trim(); attributs_lus++; } else if (xr.NodeType == XmlNodeType.Element && xr.Name == "Twitch_ID") { xr.Read(); tmpGame.TwitchGameID = xr.Value.Trim(); attributs_lus++; } else if (xr.NodeType == XmlNodeType.Element && xr.Name == "Own3D_ID") { xr.Read(); tmpGame.Own3DGameID = xr.Value.Trim(); attributs_lus++; } // Sortie de while quand tous les attributs on été lu if (attributs_lus == 3) { list.add(tmpGame); break; } } } else if (xr.NodeType == XmlNodeType.Element && xr.Name == "DefaultGame") { xr.Read(); DefaultGame = xr.Value.Trim(); } } } catch (Exception ex) { throw ex; } finally { if (xr != null) { xr.Close(); } } }