/// <summary> /// Initialize the database using the specifiec XML /// </summary> /// <param name="xml">Xml.</param> public void InitializeFromXml(string xml) { Logger.I("Initializing database from xml..."); // Parse the xml // Format: // <questions> // <question> // <id type="integer">1</id> // <gameId type="integer">1</gameId> // <image>00001.jpg</image> // <titlePAL>A-Train</titlePAL> // <titleUS>A-Train</titleUS> // <titleJAP/> // <platform>Amiga</platform> // <genre>gestion</genre> // <publisher>Ocean</publisher> // <year type="integer">1992</year> // <excluded type="trueclass">false</excluded> // </question> // </questions> int addCount = 0; XElement element = XElement.Parse (xml); foreach (XElement gameXml in element.Elements("question")) { GameEntry game = new GameEntry (); game.GameId = Convert.ToInt32 (gameXml.Element ("gameId").Value); game.ImagePath = gameXml.Element ("image").Value; game.TitlePAL = gameXml.Element ("titlePAL").Value; game.TitleUS = gameXml.Element ("titleUS").Value; game.Platform = gameXml.Element ("platform").Value; game.Genre = gameXml.Element ("genre").Value; game.Publisher = gameXml.Element ("publisher").Value; game.Year = Convert.ToInt32 (gameXml.Element ("year").Value); bool isRemoved = Convert.ToBoolean (gameXml.Element ("excluded").Value); if (isRemoved == false) { addCount++; AddGame (game); } } Logger.I("Initialization completed, " + addCount + " games added!"); }
/// <summary> /// Add a new game entry /// </summary> /// <param name="gameInfo">Game info.</param> public void AddGame(GameEntry gameInfo) { lock (mLocker) { mDb.Insert (gameInfo); } }
/// <summary> /// Get the image of a game. /// </summary> /// <param name="game">Game.</param> public string Getimage(GameEntry game) { return Path.Combine (mImagesRootLocation, game.ImagePath); }