コード例 #1
0
ファイル: XMLReader.cs プロジェクト: Giulio-Ladu/GameHub
        public void ReadGameData(string platform, Action<GameList, Exception> callback)
        {
            Exception exception = null;
            try
            {
                string uri = string.Format("GamesXML/{0}_gamesList.xml", platform);
                StreamResourceInfo SRI = Application.GetResourceStream(new Uri(uri, System.UriKind.Relative));

                XmlSerializer serializer = new XmlSerializer(typeof(GameList));
                FoundGames = (GameList)serializer.Deserialize(SRI.Stream);
            }
            catch (Exception ex)
            {
                exception = ex;
            }
            if (callback != null)
            {
                callback(FoundGames, exception);    
            }
        }
コード例 #2
0
ファイル: DataFactory.cs プロジェクト: Giulio-Ladu/GameHub
 private void PrintOutGameData(GameList gamesList)
 {
     if (gamesList != null && gamesList.Games.Count > 0)
     {
         foreach (GameResponse g in gamesList.Games)
         {
             Debug.WriteLine("Found - " + g.NameDetails.UK_Name);
         }
     }
 }
コード例 #3
0
ファイル: DataFactory.cs プロジェクト: Giulio-Ladu/GameHub
        private void HandleGameData(GameList gamesList, Exception exception)
        {
            ObservableCollection<GameData> gameDataList = new ObservableCollection<GameData>();
            if (exception == null)
            {
                GameDataContext context = new GameDataContext(Constants.DBConnectionString);
                foreach (GameResponse g in gamesList.Games)
                {
                    GameData game = new GameData(g, this.SelectedPlatform);
                    gameDataList.Add(game);
                    Debug.WriteLine("Adding " + game.UK_Name);
                    context.Games.InsertOnSubmit(game);
                }
                context.SubmitChanges();
            }
#if DEBUG
            PrintOutGameData(gamesList);
#endif
            if (this.CallBack != null)
            {
                CallBack(gameDataList, exception);    
            }
        }