static void Main(string[] args) { User user1 = new User(); user1.UserName = "******"; user1.Email = "*****@*****.**"; user1.Id = 1; user1.Password = "******"; user1.TcNo = "1234567890"; user1.Name = "Can"; user1.LastName = "Yüksel"; IVerification verification = new Verification(); UserManager userManager = new UserManager(verification); userManager.Register(user1); GameList <string> gameList = new GameList <string>(); gameList.Add("Cod4"); gameList.Add("Gta5"); gameList.Add("PUBG"); Discount discount = new Discount(); discount.Id = 1; discount.DiscountName = "NewUser"; discount.DiscountPrice = 45; Sales sale = new Sales(); sale.Sale(user1, discount, gameList); }
public void GameListJsonTest() { var gameList1 = new GameList(); gameList1.Add(new Game( 1, "Name1", "Description1")); gameList1.Add(new Game( 2, "Name2", "Description2")); gameList1.Add(new Game( 3, "Name3", "Description3")); var jsonText = CloneUtility.ToJson(gameList1); Assert.IsFalse(string.IsNullOrEmpty(jsonText)); var gameList2 = CloneUtility.FromJson <GameList>(jsonText); Assert.AreNotSame(gameList1, gameList2); Assert.AreEqual(gameList1.List.Count, gameList2.List.Count); for (var index = 0; index < gameList1.List.Count; index++) { Assert.AreEqual(gameList1.List[index].Id, gameList2.List[index].Id); Assert.AreEqual(gameList1.List[index].Name, gameList2.List[index].Name); Assert.AreEqual(gameList1.List[index].Description, gameList2.List[index].Description); } }
public void GameListExistsTest() { var gameList = new GameList(); gameList.Add(new Game( 1, "Name1", "Description1")); gameList.Add(new Game( 2, "Name2", "Description2")); gameList.Add(new Game( 3, "Name3", "Description3")); Assert.IsFalse(gameList.Exists(0)); Assert.IsFalse(gameList.Exists(-1)); Assert.AreEqual(gameList.Exists(1), true); Assert.AreEqual(gameList.Exists(2), true); Assert.AreEqual(gameList.Exists(3), true); }
public void GameListDictionaryTest() { var gameList1 = new GameList(); gameList1.Add(new Game( 1, "Name1", "Description1")); gameList1.Add(new Game( 2, "Name2", "Description2")); gameList1.Add(new Game( 3, "Name3", "Description3")); var dictionaryList = GameList.ToDictionaryList(gameList1); Assert.IsNotNull(dictionaryList); var gameList2 = GameList.FromDictionaryList(dictionaryList); Assert.AreNotSame(gameList1, gameList2); Assert.AreEqual(gameList1.List.Count, gameList2.List.Count); for (var index = 0; index < gameList1.List.Count; index++) { Assert.AreEqual(gameList1.List[index].Id, gameList2.List[index].Id); Assert.AreEqual(gameList1.List[index].Name, gameList2.List[index].Name); Assert.AreEqual(gameList1.List[index].Description, gameList2.List[index].Description); } }
public void GameListXmlCloneTest() { var gameList1 = new GameList(); gameList1.Add(new Game( 1, "Name1", "Description1")); gameList1.Add(new Game( 2, "Name2", "Description2")); gameList1.Add(new Game( 3, "Name3", "Description3")); var gameList2 = CloneUtility.XmlClone(gameList1, null); Assert.AreNotSame(gameList1, gameList2); Assert.AreEqual(gameList1.List.Count, gameList2.List.Count); for (var index = 0; index < gameList1.List.Count; index++) { Assert.AreEqual(gameList1.List[index].Id, gameList2.List[index].Id); Assert.AreEqual(gameList1.List[index].Name, gameList2.List[index].Name); Assert.AreEqual(gameList1.List[index].Description, gameList2.List[index].Description); } }
public void SearchGame(String name) { lock (queryGameLock) { GameList.Clear(); var content = XHttpGet(String.Format(urlSearchGame, HttpUtility.UrlEncode(name))); Debug.Print("Goodgame games starting from {0}: {1}", name, content); if (String.IsNullOrEmpty(content)) { return; } try { JArray games = JArray.Parse(content); if (games.Count <= 0) { return; } foreach (JArray game in games) { GameList.Add(new KeyValuePair <String, String>(game[2].ToString(), game[0].ToString())); } } catch (Exception e) { Debug.Print("Goodgame queryGameList error: {0}", e.Message); } } }
} // SendListToAll /// <summary>Добавляет строку с текущей игрой в список "В ИГРЕ"</summary> /// <param name="game">Строка кто против кого</param> public async void AddGameToGameList(string game) { GameList.Add(game); // Перебираем пользователей и шлём им новый список имён await SendGamesListToAllAsync(GameList); } // AddGameToGameList
public void Test_Serialize() { GameList gameList = new GameList(); gameList.Add(new Game() { Description = "Description", Developer = "Developer", Genre = "Genre", Id = "Id", Image = "Image", LastPlayed = "LastPlayed", Name = "Name", Path = "Path", PlayCount = "PlayCount", Players = "Players", Publisher = "Publisher", Rating = "Rating", ReleaseDate = "ReleaseDate", Source = "Source", Video = "Video" }); GameListXmlSerializer xmlSerializer = new GameListXmlSerializer(typeof(GameList)); StringWriter stringWriter = new StringWriter(); xmlSerializer.Serialize(stringWriter, gameList); string actualValue = stringWriter.ToString(); string expectedValue = "<?xml version=\"1.0\" encoding=\"utf-16\"?>\r\n<gameList>\r\n <game id=\"Id\" source=\"Source\">\r\n <desc>Description</desc>\r\n <developer>Developer</developer>\r\n <genre>Genre</genre>\r\n <image>Image</image>\r\n <lastplayed>LastPlayed</lastplayed>\r\n <name>Name</name>\r\n <path>Path</path>\r\n <playcount>PlayCount</playcount>\r\n <players>Players</players>\r\n <publisher>Publisher</publisher>\r\n <rating>Rating</rating>\r\n <releasedate>ReleaseDate</releasedate>\r\n <video>Video</video>\r\n </game>\r\n</gameList>"; Assert.Equal(expectedValue, actualValue); }
public void LoadGames() { GameList.Clear(); Directory.CreateDirectory(_mainViewModel.DataDirectory); var fileList = Directory.GetFiles(_mainViewModel.DataDirectory); foreach (var file in fileList) { var info = LoadJson(file); var gameType = _mainViewModel.GameTypes.FirstOrDefault(p => p.Extension == info.GameType); var gameInfoViewModel = new GameInfoViewModel(info, _mainViewModel.PlayerName); if (gameType != null) { gameInfoViewModel.GameTypeObject = gameType; gameInfoViewModel.IconImage = new BitmapImage(new Uri(gameType.Icon, UriKind.RelativeOrAbsolute)); } if (files.ContainsKey(info.FileName)) { gameInfoViewModel.File = files[info.FileName]; } GameList.Add(gameInfoViewModel); } }
public ActionResult Index() { var model = new GameList(); foreach (RockPaperScissorsSession game in _game.Sessions) { model.Add(new Tuple<string, string>(game.Id.ToString(), game.Name)); } return View(model); }
public void PresetGame1() { GameList.Clear(); for (int i = 0; i < 9; i++) { GameList.Add(new ObservableCollection <int>()); for (int j = 0; j < 9; j++) { GameList[i].Add(0); } } GameList[0][1] = 6; GameList[0][3] = 5; GameList[0][4] = 3; GameList[0][5] = 7; GameList[0][7] = 4; GameList[1][0] = 3; GameList[1][4] = 9; GameList[1][8] = 6; GameList[2][0] = 8; GameList[2][2] = 4; GameList[2][6] = 3; GameList[2][8] = 7; GameList[3][1] = 9; GameList[3][6] = 7; GameList[3][7] = 1; GameList[3][8] = 3; GameList[4][1] = 5; GameList[4][2] = 1; GameList[4][6] = 6; GameList[4][7] = 2; GameList[5][0] = 2; GameList[5][1] = 3; GameList[5][2] = 8; GameList[5][7] = 4; GameList[6][0] = 3; GameList[6][2] = 6; GameList[6][6] = 1; GameList[6][8] = 2; GameList[7][0] = 4; GameList[7][4] = 6; GameList[7][8] = 9; GameList[8][1] = 1; GameList[8][3] = 5; GameList[8][4] = 2; GameList[8][5] = 3; GameList[8][7] = 8; }
public void GameListAddandRemoveTest() { var gameList = new GameList(); Assert.AreEqual(gameList.List.Count, 0); gameList.Add(new Game( 1, "Name1", "Description1")); Assert.AreEqual(gameList.List.Count, 1); gameList.Add(new Game( 2, "Name2", "Description2")); Assert.AreEqual(gameList.List.Count, 2); gameList.Add(new Game( 3, "Name3", "Description3")); Assert.AreEqual(gameList.List.Count, 3); gameList.Remove(1); Assert.AreEqual(gameList.List.Count, 2); gameList.Remove(3); Assert.AreEqual(gameList.List.Count, 1); gameList.Remove(2); Assert.AreEqual(gameList.List.Count, 0); }
public void GameListGetByIdTest() { var gameList = new GameList(); var guid1 = Guid.NewGuid(); var guid2 = Guid.NewGuid(); var guid3 = Guid.NewGuid(); gameList.Add(new Game( 1, "Name1", "Description1")); gameList.Add(new Game( 2, "Name2", "Description2")); gameList.Add(new Game( 3, "Name3", "Description3")); var game = gameList.GetById(0); Assert.AreEqual(game, null); game = gameList.GetById(-1); Assert.AreEqual(game, null); game = gameList.GetById(1); Assert.AreEqual(game.Name, "Name1"); game = gameList.GetById(2); Assert.AreEqual(game.Name, "Name2"); game = gameList.GetById(3); Assert.AreEqual(game.Name, "Name3"); }
private void LoadGameList(string yearIn) { Logger.Trace(string.Format("LoadGameList: Loading {0} game List...", yearIn)); if (GameList == null) { GameList = new List <NFLGame>(); } var gameDt = Utility.TflWs.GetSeasonDt(yearIn); foreach (var g in from DataRow dr in gameDt.Rows select new NFLGame(dr)) { GameList.Add(g); } Logger.Trace($"LoadGameList: Loaded {GameList.Count} games."); }
public void loadConfig() { XmlDocument xd = new XmlDocument(); xd.Load(Path.Combine(Application.StartupPath, "config.xml")); DefaultItem = GameItem.parseXmlNode(xd.SelectSingleNode("config/gamelist/defaultitem"), null); GameList.Clear(); XmlNodeList xnList = xd.SelectNodes("config/gamelist/gameitem"); foreach (XmlNode xn in xnList) { GameList.Add(GameItem.parseXmlNode(xn, DefaultItem)); } Current = GameList[0]; }
private void LoadGameList(string yearIn) { #if DEBUG Utility.Announce(string.Format("LoadGameList: Loading {0} game List...", yearIn)); #endif if (GameList == null) { GameList = new List <NFLGame>(); } var gameDt = Utility.TflWs.GetSeasonDt(yearIn); foreach (var g in from DataRow dr in gameDt.Rows select new NFLGame(dr)) { GameList.Add(g); } #if DEBUG Utility.Announce(string.Format("LoadGameList: Loaded {0} games.", GameList.Count)); #endif }
public override void OnRoomListUpdate(List <RoomInfo> roomList) { base.OnRoomListUpdate(roomList); mDebug.text += "OnRoomListUpdate \n"; mDebug.text += $"Now there are {roomList.Count} rooms \n\n"; list.Clear(); RoomInfo.Clear(); for (int i = 0; i < roomList.Count; i++) { if (roomList[i].PlayerCount > 0) { list.Add(roomList[i].Name + roomList[i] .CustomProperties["masterclientnickname"], roomList[i].PlayerCount, roomList[i].MaxPlayers); RoomInfo.Add(roomList[i]); mDebug.text += $"Room ID {i} Name: " + roomList[i].Name + "\n"; } } }
/// <summary> /// Tworzy nowy stol do gry i pilnuje rozgrywki, zamyka watek gdy liczba graczy wyniesie 0 na danym stole /// </summary> private void CreateGame(TableModel table) { //Nowy wątek gry var Game = new Game(); Game.Initialize(table); Game.OnBeforeGameStartEvent += (game) => { RemovePlayers(game); }; Game.OnGameFinishedEvent += (game) => { UpdateTournamentModel(); }; GameList.Add(Game); }
public GameList SelectByUsersId(int u1, int u2) { GameList u1Games = this.SelectByUserId(u1); GameList u2Games = this.SelectByUserId(u2); GameList mutualGames = new GameList(); foreach (Game g1 in u1Games) { foreach (Game g2 in u2Games) { if (g1.Id == g2.Id) { mutualGames.Add(g1); } } } return(mutualGames); }
private void queryGameList(String name) { lock (queryGameLock) { GameList.Clear(); var content = HtmlGet(String.Format(urlSearchGame, HttpUtility.UrlEncode(name)), String.Empty); Debug.Print("Twitch games starting from {0}: {1}", name, content); if (String.IsNullOrEmpty(content)) { return; } try { JArray games = JArray.Parse(content); if (games.Count <= 0) { return; } foreach (JObject game in games) { GameList.Add(new KeyValuePair <String, String>(game["id"].ToString(), game["name"].ToString())); } } catch (Exception e) { Debug.Print("TwitchWeb queryGameList error: {0}", e.Message); } //Twitch games: [{"name":"War Thunder","id":66366,"giantbombId":38992,"images":{"icon":"http://static.giantbomb.com/uploads/square_avatar/13/138444/2295942-w_warthunder_keyart_small.jpg","tiny":"http://static.giantbomb.com/uploads/square_mini/13/138444/2295942-w_warthunder_keyart_small.jpg","small":"http://static.giantbomb.com/uploads/scale_small/13/138444/2295942-w_warthunder_keyart_small.jpg","super":"http://static.giantbomb.com/uploads/scale_large/13/138444/2295942-w_warthunder_keyart_small.jpg","thumb":"http://static.giantbomb.com/uploads/scale_avatar/13/138444/2295942-w_warthunder_keyart_small.jpg","medium":"http://static.giantbomb.com/uploads/scale_medium/13/138444/2295942-w_warthunder_keyart_small.jpg","screen":"http://static.giantbomb.com/uploads/screen_medium/13/138444/2295942-w_warthunder_keyart_small.jpg"},"popularity":11,"boxArt":{"template":"http://static-cdn.jtvnw.net/ttv-boxart/War%20Thunder-{width}x{height}.jpg","small":"http://static-cdn.jtvnw.net/ttv-boxart/War%20Thunder-52x72.jpg","medium":"http://static-cdn.jtvnw.net/ttv-boxart/War%20Thunder-136x190.jpg","large":"http://static-cdn.jtvnw.net/ttv-boxart/War%20Thunder-272x380.jpg"},"logoArt":{"template":"http://static-cdn.jtvnw.net/ttv-logoart/War%20Thunder-{width}x{height}.jpg","small":"http://static-cdn.jtvnw.net/ttv-logoart/War%20Thunder-60x36.jpg","medium":"http://static-cdn.jtvnw.net/ttv-logoart/War%20Thunder-120x72.jpg","large":"http://static-cdn.jtvnw.net/ttv-logoart/War%20Thunder-240x144.jpg"}},{"name":"War of The Immortals","id":33218,"giantbombId":37035,"images":{"icon":"http://static.giantbomb.com/uploads/square_avatar/8/87749/2080224-war_of_the_immortals_logo.jpg","tiny":"http://static.giantbomb.com/uploads/square_mini/8/87749/2080224-war_of_the_immortals_logo.jpg","small":"http://static.giantbomb.com/uploads/scale_small/8/87749/2080224-war_of_the_immortals_logo.jpg","super":"http://static.giantbomb.com/uploads/scale_large/8/87749/2080224-war_of_the_immortals_logo.jpg","thumb":"http://static.giantbomb.com/uploads/scale_avatar/8/87749/2080224-war_of_the_immortals_logo.jpg","medium":"http://static.giantbomb.com/uploads/scale_medium/8/87749/2080224-war_of_the_immortals_logo.jpg","screen":"http://static.giantbomb.com/uploads/screen_medium/8/87749/2080224-war_of_the_immortals_logo.jpg"},"popularity":1,"boxArt":{"template":"http://static-cdn.jtvnw.net/ttv-boxart/War%20of%20The%20Immortals-{width}x{height}.jpg","small":"http://static-cdn.jtvnw.net/ttv-boxart/War%20of%20The%20Immortals-52x72.jpg","medium":"http://static-cdn.jtvnw.net/ttv-boxart/War%20of%20The%20Immortals-136x190.jpg","large":"http://static-cdn.jtvnw.net/ttv-boxart/War%20of%20The%20Immortals-272x380.jpg"},"logoArt":{"template":"http://static-cdn.jtvnw.net/ttv-logoart/War%20of%20The%20Immortals-{width}x{height}.jpg","small":"http://static-cdn.jtvnw.net/ttv-logoart/War%20of%20The%20Immortals-60x36.jpg","medium":"http://static-cdn.jtvnw.net/ttv-logoart/War%20of%20The%20Immortals-120x72.jpg","large":"http://static-cdn.jtvnw.net/ttv-logoart/War%20of%20The%20Immortals-240x144.jpg"}},{"name":"War of the Vikings","id":313414,"giantbombId":43504,"images":{"icon":"http://static.giantbomb.com/uploads/square_avatar/2/22486/2528199-war_of_the_vikings_plaza_banner.jpg","tiny":"http://static.giantbomb.com/uploads/square_mini/2/22486/2528199-war_of_the_vikings_plaza_banner.jpg","small":"http://static.giantbomb.com/uploads/scale_small/2/22486/2528199-war_of_the_vikings_plaza_banner.jpg","super":"http://static.giantbomb.com/uploads/scale_large/2/22486/2528199-war_of_the_vikings_plaza_banner.jpg","thumb":"http://static.giantbomb.com/uploads/scale_avatar/2/22486/2528199-war_of_the_vikings_plaza_banner.jpg","medium":"http://static.giantbomb.com/uploads/scale_medium/2/22486/2528199-war_of_the_vikings_plaza_banner.jpg","screen":"http://static.giantbomb.com/uploads/screen_medium/2/22486/2528199-war_of_the_vikings_plaza_banner.jpg"},"popularity":1,"boxArt":{"template":"http://static-cdn.jtvnw.net/ttv-boxart/War%20of%20the%20Vikings-{width}x{height}.jpg","small":"http://static-cdn.jtvnw.net/ttv-boxart/War%20of%20the%20Vikings-52x72.jpg","medium":"http://static-cdn.jtvnw.net/ttv-boxart/War%20of%20the%20Vikings-136x190.jpg","large":"http://static-cdn.jtvnw.net/ttv-boxart/War%20of%20the%20Vikings-272x380.jpg"},"logoArt":{"template":"http://static-cdn.jtvnw.net/ttv-logoart/War%20of%20the%20Vikings-{width}x{height}.jpg","small":"http://static-cdn.jtvnw.net/ttv-logoart/War%20of%20the%20Vikings-60x36.jpg","medium":"http://static-cdn.jtvnw.net/ttv-logoart/War%20of%20the%20Vikings-120x72.jpg","large":"http://static-cdn.jtvnw.net/ttv-logoart/War%20of%20the%20Vikings-240x144.jpg"}},{"name":"War of the Roses","id":32448,"giantbombId":36170,"images":{"icon":"http://static.giantbomb.com/uploads/square_avatar/8/87790/2323889-box_wotr.png","tiny":"http://static.giantbomb.com/uploads/square_mini/8/87790/2323889-box_wotr.png","small":"http://static.giantbomb.com/uploads/scale_small/8/87790/2323889-box_wotr.png","super":"http://static.giantbomb.com/uploads/scale_large/8/87790/2323889-box_wotr.png","thumb":"http://static.giantbomb.com/uploads/scale_avatar/8/87790/2323889-box_wotr.png","medium":"http://static.giantbomb.com/uploads/scale_medium/8/87790/2323889-box_wotr.png","screen":"http://static.giantbomb.com/uploads/screen_medium/8/87790/2323889-box_wotr.png"},"popularity":1,"boxArt":{"template":"http://static-cdn.jtvnw.net/ttv-boxart/War%20of%20the%20Roses-{width}x{height}.jpg","small":"http://static-cdn.jtvnw.net/ttv-boxart/War%20of%20the%20Roses-52x72.jpg","medium":"http://static-cdn.jtvnw.net/ttv-boxart/War%20of%20the%20Roses-136x190.jpg","large":"http://static-cdn.jtvnw.net/ttv-boxart/War%20of%20the%20Roses-272x380.jpg"},"logoArt":{"template":"http://static-cdn.jtvnw.net/ttv-logoart/War%20of%20the%20Roses-{width}x{height}.jpg","small":"http://static-cdn.jtvnw.net/ttv-logoart/War%20of%20the%20Roses-60x36.jpg","medium":"http://static-cdn.jtvnw.net/ttv-logoart/War%20of%20the%20Roses-120x72.jpg","large":"http://static-cdn.jtvnw.net/ttv-logoart/War%20of%20the%20Roses-240x144.jpg"}},{"name":"WarRock","id":20179,"giantbombId":22218,"images":{"icon":"http://static.giantbomb.com/uploads/square_avatar/0/217/326247-warrock_cover.jpg","tiny":"http://static.giantbomb.com/uploads/square_mini/0/217/326247-warrock_cover.jpg","small":"http://static.giantbomb.com/uploads/scale_small/0/217/326247-warrock_cover.jpg","super":"http://static.giantbomb.com/uploads/scale_large/0/217/326247-warrock_cover.jpg","thumb":"http://static.giantbomb.com/uploads/scale_avatar/0/217/326247-warrock_cover.jpg","medium":"http://static.giantbomb.com/uploads/scale_medium/0/217/326247-warrock_cover.jpg","screen":"http://static.giantbomb.com/uploads/screen_medium/0/217/326247-warrock_cover.jpg"},"popularity":1,"boxArt":{"template":"http://static-cdn.jtvnw.net/ttv-boxart/WarRock-{width}x{height}.jpg","small":"http://static-cdn.jtvnw.net/ttv-boxart/WarRock-52x72.jpg","medium":"http://static-cdn.jtvnw.net/ttv-boxart/WarRock-136x190.jpg","large":"http://static-cdn.jtvnw.net/ttv-boxart/WarRock-272x380.jpg"},"logoArt":{"template":"http://static-cdn.jtvnw.net/ttv-logoart/WarRock-{width}x{height}.jpg","small":"http://static-cdn.jtvnw.net/ttv-logoart/WarRock-60x36.jpg","medium":"http://static-cdn.jtvnw.net/ttv-logoart/WarRock-120x72.jpg","large":"http://static-cdn.jtvnw.net/ttv-logoart/WarRock-240x144.jpg"}},{"name":"War of the Dead","id":30448,"giantbombId":33862,"images":{"icon":"http://static.giantbomb.com/uploads/square_avatar/9/97089/1684417-wardeadcover.png","tiny":"http://static.giantbomb.com/uploads/square_mini/9/97089/1684417-wardeadcover.png","small":"http://static.giantbomb.com/uploads/scale_small/9/97089/1684417-wardeadcover.png","super":"http://static.giantbomb.com/uploads/scale_large/9/97089/1684417-wardeadcover.png","thumb":"http://static.giantbomb.com/uploads/scale_avatar/9/97089/1684417-wardeadcover.png","medium":"http://static.giantbomb.com/uploads/scale_medium/9/97089/1684417-wardeadcover.png","screen":"http://static.giantbomb.com/uploads/screen_medium/9/97089/1684417-wardeadcover.png"},"popularity":1,"boxArt":{"template":"http://static-cdn.jtvnw.net/ttv-boxart/War%20of%20the%20Dead-{width}x{height}.jpg","small":"http://static-cdn.jtvnw.net/ttv-boxart/War%20of%20the%20Dead-52x72.jpg","medium":"http://static-cdn.jtvnw.net/ttv-boxart/War%20of%20the%20Dead-136x190.jpg","large":"http://static-cdn.jtvnw.net/ttv-boxart/War%20of%20the%20Dead-272x380.jpg"},"logoArt":{"template":"http://static-cdn.jtvnw.net/ttv-logoart/War%20of%20the%20Dead-{width}x{height}.jpg","small":"http://static-cdn.jtvnw.net/ttv-logoart/War%20of%20the%20Dead-60x36.jpg","medium":"http://static-cdn.jtvnw.net/ttv-logoart/War%20of%20the%20Dead-120x72.jpg","large":"http://static-cdn.jtvnw.net/ttv-logoart/War%20of%20the%20Dead-240x144.jpg"}},{"name":"War Inc. Battlezone","id":32222,"giantbombId":35923,"images":{"icon":"http://static.giantbomb.com/uploads/square_avatar/0/4344/1842275-warinc_wallpaper1_1920x1080.jpg","tiny":"http://static.giantbomb.com/uploads/square_mini/0/4344/1842275-warinc_wallpaper1_1920x1080.jpg","small":"http://static.giantbomb.com/uploads/scale_small/0/4344/1842275-warinc_wallpaper1_1920x1080.jpg","super":"http://static.giantbomb.com/uploads/scale_large/0/4344/1842275-warinc_wallpaper1_1920x1080.jpg","thumb":"http://static.giantbomb.com/uploads/scale_avatar/0/4344/1842275-warinc_wallpaper1_1920x1080.jpg","medium":"http://static.giantbomb.com/uploads/scale_medium/0/4344/1842275-warinc_wallpaper1_1920x1080.jpg","screen":"http://static.giantbomb.com/uploads/screen_medium/0/4344/1842275-warinc_wallpaper1_1920x1080.jpg"},"popularity":1,"boxArt":{"template":"http://static-cdn.jtvnw.net/ttv-boxart/War%20Inc.%20Battlezone-{width}x{height}.jpg","small":"http://static-cdn.jtvnw.net/ttv-boxart/War%20Inc.%20Battlezone-52x72.jpg","medium":"http://static-cdn.jtvnw.net/ttv-boxart/War%20Inc.%20Battlezone-136x190.jpg","large":"http://static-cdn.jtvnw.net/ttv-boxart/War%20Inc.%20Battlezone-272x380.jpg"},"logoArt":{"template":"http://static-cdn.jtvnw.net/ttv-logoart/War%20Inc.%20Battlezone-{width}x{height}.jpg","small":"http://static-cdn.jtvnw.net/ttv-logoart/War%20Inc.%20Battlezone-60x36.jpg","medium":"http://static-cdn.jtvnw.net/ttv-logoart/War%20Inc.%20Battlezone-120x72.jpg","large":"http://static-cdn.jtvnw.net/ttv-logoart/War%20Inc.%20Battlezone-240x144.jpg"}},{"name":"War Zone","id":3662,"giantbombId":4016,"images":{},"popularity":null,"boxArt":{"template":"http://static-cdn.jtvnw.net/ttv-boxart/War%20Zone-{width}x{height}.jpg","small":"http://static-cdn.jtvnw.net/ttv-boxart/War%20Zone-52x72.jpg","medium":"http://static-cdn.jtvnw.net/ttv-boxart/War%20Zone-136x190.jpg","large":"http://static-cdn.jtvnw.net/ttv-boxart/War%20Zone-272x380.jpg"},"logoArt":{"template":"http://static-cdn.jtvnw.net/ttv-logoart/War%20Zone-{width}x{height}.jpg","small":"http://static-cdn.jtvnw.net/ttv-logoart/War%20Zone-60x36.jpg","medium":"http://static-cdn.jtvnw.net/ttv-logoart/War%20Zone-120x72.jpg","large":"http://static-cdn.jtvnw.net/ttv-logoart/War%20Zone-240x144.jpg"}},{"name":"War Chess","id":3201,"giantbombId":3492,"images":{},"popularity":null,"boxArt":{"template":"http://static-cdn.jtvnw.net/ttv-boxart/War%20Chess-{width}x{height}.jpg","small":"http://static-cdn.jtvnw.net/ttv-boxart/War%20Chess-52x72.jpg","medium":"http://static-cdn.jtvnw.net/ttv-boxart/War%20Chess-136x190.jpg","large":"http://static-cdn.jtvnw.net/ttv-boxart/War%20Chess-272x380.jpg"},"logoArt":{"template":"http://static-cdn.jtvnw.net/ttv-logoart/War%20Chess-{width}x{height}.jpg","small":"http://static-cdn.jtvnw.net/ttv-logoart/War%20Chess-60x36.jpg","medium":"http://static-cdn.jtvnw.net/ttv-logoart/War%20Chess-120x72.jpg","large":"http://static-cdn.jtvnw.net/ttv-logoart/War%20Chess-240x144.jpg"}},{"name":"War Machine","id":13037,"giantbombId":14205,"images":{},"popularity":null,"boxArt":{"template":"http://static-cdn.jtvnw.net/ttv-boxart/War%20Machine-{width}x{height}.jpg","small":"http://static-cdn.jtvnw.net/ttv-boxart/War%20Machine-52x72.jpg","medium":"http://static-cdn.jtvnw.net/ttv-boxart/War%20Machine-136x190.jpg","large":"http://static-cdn.jtvnw.net/ttv-boxart/War%20Machine-272x380.jpg"},"logoArt":{"template":"http://static-cdn.jtvnw.net/ttv-logoart/War%20Machine-{width}x{height}.jpg","small":"http://static-cdn.jtvnw.net/ttv-logoart/War%20Machine-60x36.jpg","medium":"http://static-cdn.jtvnw.net/ttv-logoart/War%20Machine-120x72.jpg","large":"http://static-cdn.jtvnw.net/ttv-logoart/War%20Machine-240x144.jpg"}},{"name":"War of the Dead Part 2","id":30447,"giantbombId":33863,"images":{"icon":"http://static.giantbomb.com/uploads/square_avatar/9/97089/1682802-warcover2.png","tiny":"http://static.giantbomb.com/uploads/square_mini/9/97089/1682802-warcover2.png","small":"http://static.giantbomb.com/uploads/scale_small/9/97089/1682802-warcover2.png","super":"http://static.giantbomb.com/uploads/scale_large/9/97089/1682802-warcover2.png","thumb":"http://static.giantbomb.com/uploads/scale_avatar/9/97089/1682802-warcover2.png","medium":"http://static.giantbomb.com/uploads/scale_medium/9/97089/1682802-warcover2.png","screen":"http://static.giantbomb.com/uploads/screen_medium/9/97089/1682802-warcover2.png"},"popularity":null,"boxArt":{"template":"http://static-cdn.jtvnw.net/ttv-boxart/War%20of%20the%20Dead%20Part%202-{width}x{height}.jpg","small":"http://static-cdn.jtvnw.net/ttv-boxart/War%20of%20the%20Dead%20Part%202-52x72.jpg","medium":"http://static-cdn.jtvnw.net/ttv-boxart/War%20of%20the%20Dead%20Part%202-136x190.jpg","large":"http://static-cdn.jtvnw.net/ttv-boxart/War%20of%20the%20Dead%20Part%202-272x380.jpg"},"logoArt":{"template":"http://static-cdn.jtvnw.net/ttv-logoart/War%20of%20the%20Dead%20Part%202-{width}x{height}.jpg","small":"http://static-cdn.jtvnw.net/ttv-logoart/War%20of%20the%20Dead%20Part%202-60x36.jpg","medium":"http://static-cdn.jtvnw.net/ttv-logoart/War%20of%20the%20Dead%20Part%202-120x72.jpg","large":"http://static-cdn.jtvnw.net/ttv-logoart/War%20of%20the%20Dead%20Part%202-240x144.jpg"}},{"name":"War of Genesis III","id":21116,"giantbombId":23280,"images":{"icon":"http://static.giantbomb.com/uploads/square_avatar/0/5128/554470-logo.jpg","tiny":"http://static.giantbomb.com/uploads/square_mini/0/5128/554470-logo.jpg","small":"http://static.giantbomb.com/uploads/scale_small/0/5128/554470-logo.jpg","super":"http://static.giantbomb.com/uploads/scale_large/0/5128/554470-logo.jpg","thumb":"http://static.giantbomb.com/uploads/scale_avatar/0/5128/554470-logo.jpg","medium":"http://static.giantbomb.com/uploads/scale_medium/0/5128/554470-logo.jpg","screen":"http://static.giantbomb.com/uploads/screen_medium/0/5128/554470-logo.jpg"},"popularity":null,"boxArt":{"template":"http://static-cdn.jtvnw.net/ttv-boxart/War%20of%20Genesis%20III-{width}x{height}.jpg","small":"http://static-cdn.jtvnw.net/ttv-boxart/War%20of%20Genesis%20III-52x72.jpg","medium":"http://static-cdn.jtvnw.net/ttv-boxart/War%20of%20Genesis%20III-136x190.jpg","large":"http://static-cdn.jtvnw.net/ttv-boxart/War%20of%20Genesis%20III-272x380.jpg"},"logoArt":{"template":"http://static-cdn.jtvnw.net/ttv-logoart/War%20of%20Genesis%20III-{width}x{height}.jpg","small":"http://static-cdn.jtvnw.net/ttv-logoart/War%20of%20Genesis%20III-60x36.jpg","medium":"http://static-cdn.jtvnw.net/ttv-logoart/War%20of%20Genesis%20III-120x72.jpg","large":"http://static-cdn.jtvnw.net/ttv-logoart/War%20of%20Genesis%20III-240x144.jpg"}},{"name":"War World: Tactical Combat","id":15867,"giantbombId":17302,"images":{"icon":"http://static.giantbomb.com/uploads/square_avatar/8/87790/1858027-box_wwtc.png","tiny":"http://static.giantbomb.com/uploads/square_mini/8/87790/1858027-box_wwtc.png","small":"http://static.giantbomb.com/uploads/scale_small/8/87790/1858027-box_wwtc.png","super":"http://static.giantbomb.com/uploads/scale_large/8/87790/1858027-box_wwtc.png","thumb":"http://static.giantbomb.com/uploads/scale_avatar/8/87790/1858027-box_wwtc.png","medium":"http://static.giantbomb.com/uploads/scale_medium/8/87790/1858027-box_wwtc.png","screen":"http://static.giantbomb.com/uploads/screen_medium/8/87790/1858027-box_wwtc.png"},"popularity":null,"boxArt":{"template":"http://static-cdn.jtvnw.net/ttv-boxart/War%20World%3A%20Tactical%20Combat-{width}x{height}.jpg","small":"http://static-cdn.jtvnw.net/ttv-boxart/War%20World%3A%20Tactical%20Combat-52x72.jpg","medium":"http://static-cdn.jtvnw.net/ttv-boxart/War%20World%3A%20Tactical%20Combat-136x190.jpg","large":"http://static-cdn.jtvnw.net/ttv-boxart/War%20World%3A%20Tactical%20Combat-272x380.jpg"},"logoArt":{"template":"http://static-cdn.jtvnw.net/ttv-logoart/War%20World%3A%20Tactical%20Combat-{width}x{height}.jpg","small":"http://static-cdn.jtvnw.net/ttv-logoart/War%20World%3A%20Tactical%20Combat-60x36.jpg","medium":"http://static-cdn.jtvnw.net/ttv-logoart/War%20World%3A%20Tactical%20Combat-120x72.jpg","large":"http://static-cdn.jtvnw.net/ttv-logoart/War%20World%3A%20Tactical%20Combat-240x144.jpg"}},{"name":"War of Eclipse","id":99264,"giantbombId":40987,"images":{"icon":"http://static.giantbomb.com/uploads/square_avatar/2/24833/2402501-war_of_eclipse.png","tiny":"http://static.giantbomb.com/uploads/square_mini/2/24833/2402501-war_of_eclipse.png","small":"http://static.giantbomb.com/uploads/scale_small/2/24833/2402501-war_of_eclipse.png","super":"http://static.giantbomb.com/uploads/scale_large/2/24833/2402501-war_of_eclipse.png","thumb":"http://static.giantbomb.com/uploads/scale_avatar/2/24833/2402501-war_of_eclipse.png","medium":"http://static.giantbomb.com/uploads/scale_medium/2/24833/2402501-war_of_eclipse.png","screen":"http://static.giantbomb.com/uploads/screen_medium/2/24833/2402501-war_of_eclipse.png"},"popularity":null,"boxArt":{"template":"http://static-cdn.jtvnw.net/ttv-boxart/War%20of%20Eclipse-{width}x{height}.jpg","small":"http://static-cdn.jtvnw.net/ttv-boxart/War%20of%20Eclipse-52x72.jpg","medium":"http://static-cdn.jtvnw.net/ttv-boxart/War%20of%20Eclipse-136x190.jpg","large":"http://static-cdn.jtvnw.net/ttv-boxart/War%20of%20Eclipse-272x380.jpg"},"logoArt":{"template":"http://static-cdn.jtvnw.net/ttv-logoart/War%20of%20Eclipse-{width}x{height}.jpg","small":"http://static-cdn.jtvnw.net/ttv-logoart/War%20of%20Eclipse-60x36.jpg","medium":"http://static-cdn.jtvnw.net/ttv-logoart/War%20of%20Eclipse-120x72.jpg","large":"http://static-cdn.jtvnw.net/ttv-logoart/War%20of%20Eclipse-240x144.jpg"}},{"name":"War of Nerves!","id":1004,"giantbombId":1100,"images":{"icon":"http://static.giantbomb.com/uploads/square_avatar/0/5278/288486-war_of_nerves.jpg","tiny":"http://static.giantbomb.com/uploads/square_mini/0/5278/288486-war_of_nerves.jpg","small":"http://static.giantbomb.com/uploads/scale_small/0/5278/288486-war_of_nerves.jpg","super":"http://static.giantbomb.com/uploads/scale_large/0/5278/288486-war_of_nerves.jpg","thumb":"http://static.giantbomb.com/uploads/scale_avatar/0/5278/288486-war_of_nerves.jpg","medium":"http://static.giantbomb.com/uploads/scale_medium/0/5278/288486-war_of_nerves.jpg","screen":"http://static.giantbomb.com/uploads/screen_medium/0/5278/288486-war_of_nerves.jpg"},"popularity":null,"boxArt":{"template":"http://static-cdn.jtvnw.net/ttv-boxart/War%20of%20Nerves!-{width}x{height}.jpg","small":"http://static-cdn.jtvnw.net/ttv-boxart/War%20of%20Nerves!-52x72.jpg","medium":"http://static-cdn.jtvnw.net/ttv-boxart/War%20of%20Nerves!-136x190.jpg","large":"http://static-cdn.jtvnw.net/ttv-boxart/War%20of%20Nerves!-272x380.jpg"},"logoArt":{"template":"http://static-cdn.jtvnw.net/ttv-logoart/War%20of%20Nerves!-{width}x{height}.jpg","small":"http://static-cdn.jtvnw.net/ttv-logoart/War%20of%20Nerves!-60x36.jpg","medium":"http://static-cdn.jtvnw.net/ttv-logoart/War%20of%20Nerves!-120x72.jpg","large":"http://static-cdn.jtvnw.net/ttv-logoart/War%20of%20Nerves!-240x144.jpg"}},{"name":"War of Sonria","id":93310,"giantbombId":40857,"images":{"icon":"http://static.giantbomb.com/uploads/square_avatar/14/149021/2388377-warofsonria_featuredimage.jpg","tiny":"http://static.giantbomb.com/uploads/square_mini/14/149021/2388377-warofsonria_featuredimage.jpg","small":"http://static.giantbomb.com/uploads/scale_small/14/149021/2388377-warofsonria_featuredimage.jpg","super":"http://static.giantbomb.com/uploads/scale_large/14/149021/2388377-warofsonria_featuredimage.jpg","thumb":"http://static.giantbomb.com/uploads/scale_avatar/14/149021/2388377-warofsonria_featuredimage.jpg","medium":"http://static.giantbomb.com/uploads/scale_medium/14/149021/2388377-warofsonria_featuredimage.jpg","screen":"http://static.giantbomb.com/uploads/screen_medium/14/149021/2388377-warofsonria_featuredimage.jpg"},"popularity":null,"boxArt":{"template":"http://static-cdn.jtvnw.net/ttv-boxart/War%20of%20Sonria-{width}x{height}.jpg","small":"http://static-cdn.jtvnw.net/ttv-boxart/War%20of%20Sonria-52x72.jpg","medium":"http://static-cdn.jtvnw.net/ttv-boxart/War%20of%20Sonria-136x190.jpg","large":"http://static-cdn.jtvnw.net/ttv-boxart/War%20of%20Sonria-272x380.jpg"},"logoArt":{"template":"http://static-cdn.jtvnw.net/ttv-logoart/War%20of%20Sonria-{width}x{height}.jpg","small":"http://static-cdn.jtvnw.net/ttv-logoart/War%20of%20Sonria-60x36.jpg","medium":"http://static-cdn.jtvnw.net/ttv-logoart/War%20of%20Sonria-120x72.jpg","large":"http://static-cdn.jtvnw.net/ttv-logoart/War%20of%20Sonria-240x144.jpg"}},{"name":"War of the Lance","id":16844,"giantbombId":18379,"images":{"icon":"http://static.giantbomb.com/uploads/square_avatar/1/15693/614756-916888_40937_front_1_.jpg","tiny":"http://static.giantbomb.com/uploads/square_mini/1/15693/614756-916888_40937_front_1_.jpg","small":"http://static.giantbomb.com/uploads/scale_small/1/15693/614756-916888_40937_front_1_.jpg","super":"http://static.giantbomb.com/uploads/scale_large/1/15693/614756-916888_40937_front_1_.jpg","thumb":"http://static.giantbomb.com/uploads/scale_avatar/1/15693/614756-916888_40937_front_1_.jpg","medium":"http://static.giantbomb.com/uploads/scale_medium/1/15693/614756-916888_40937_front_1_.jpg","screen":"http://static.giantbomb.com/uploads/screen_medium/1/15693/614756-916888_40937_front_1_.jpg"},"popularity":null,"boxArt":{"template":"http://static-cdn.jtvnw.net/ttv-boxart/War%20of%20the%20Lance-{width}x{height}.jpg","small":"http://static-cdn.jtvnw.net/ttv-boxart/War%20of%20the%20Lance-52x72.jpg","medium":"http://static-cdn.jtvnw.net/ttv-boxart/War%20of%20the%20Lance-136x190.jpg","large":"http://static-cdn.jtvnw.net/ttv-boxart/War%20of%20the%20Lance-272x380.jpg"},"logoArt":{"template":"http://static-cdn.jtvnw.net/ttv-logoart/War%20of%20the%20Lance-{width}x{height}.jpg","small":"http://static-cdn.jtvnw.net/ttv-logoart/War%20of%20the%20Lance-60x36.jpg","medium":"http://static-cdn.jtvnw.net/ttv-logoart/War%20of%20the%20Lance-120x72.jpg","large":"http://static-cdn.jtvnw.net/ttv-logoart/War%20of%20the%20Lance-240x144.jpg"}},{"name":"War Front: Turning Point","id":18466,"giantbombId":20195,"images":{"icon":"http://static.giantbomb.com/uploads/square_avatar/0/1379/1293229-war_front___turning_point_coverart.png","tiny":"http://static.giantbomb.com/uploads/square_mini/0/1379/1293229-war_front___turning_point_coverart.png","small":"http://static.giantbomb.com/uploads/scale_small/0/1379/1293229-war_front___turning_point_coverart.png","super":"http://static.giantbomb.com/uploads/scale_large/0/1379/1293229-war_front___turning_point_coverart.png","thumb":"http://static.giantbomb.com/uploads/scale_avatar/0/1379/1293229-war_front___turning_point_coverart.png","medium":"http://static.giantbomb.com/uploads/scale_medium/0/1379/1293229-war_front___turning_point_coverart.png","screen":"http://static.giantbomb.com/uploads/screen_medium/0/1379/1293229-war_front___turning_point_coverart.png"},"popularity":null,"boxArt":{"template":"http://static-cdn.jtvnw.net/ttv-boxart/War%20Front%3A%20Turning%20Point-{width}x{height}.jpg","small":"http://static-cdn.jtvnw.net/ttv-boxart/War%20Front%3A%20Turning%20Point-52x72.jpg","medium":"http://static-cdn.jtvnw.net/ttv-boxart/War%20Front%3A%20Turning%20Point-136x190.jpg","large":"http://static-cdn.jtvnw.net/ttv-boxart/War%20Front%3A%20Turning%20Point-272x380.jpg"},"logoArt":{"template":"http://static-cdn.jtvnw.net/ttv-logoart/War%20Front%3A%20Turning%20Point-{width}x{height}.jpg","small":"http://static-cdn.jtvnw.net/ttv-logoart/War%20Front%3A%20Turning%20Point-60x36.jpg","medium":"http://static-cdn.jtvnw.net/ttv-logoart/War%20Front%3A%20Turning%20Point-120x72.jpg","large":"http://static-cdn.jtvnw.net/ttv-logoart/War%20Front%3A%20Turning%20Point-240x144.jpg"}},{"name":"War of Angels","id":29310,"giantbombId":32565,"images":{"icon":"http://static.giantbomb.com/uploads/square_avatar/16/160705/2239727-warofangelsboxart.jpg","tiny":"http://static.giantbomb.com/uploads/square_mini/16/160705/2239727-warofangelsboxart.jpg","small":"http://static.giantbomb.com/uploads/scale_small/16/160705/2239727-warofangelsboxart.jpg","super":"http://static.giantbomb.com/uploads/scale_large/16/160705/2239727-warofangelsboxart.jpg","thumb":"http://static.giantbomb.com/uploads/scale_avatar/16/160705/2239727-warofangelsboxart.jpg","medium":"http://static.giantbomb.com/uploads/scale_medium/16/160705/2239727-warofangelsboxart.jpg","screen":"http://static.giantbomb.com/uploads/screen_medium/16/160705/2239727-warofangelsboxart.jpg"},"popularity":null,"boxArt":{"template":"http://static-cdn.jtvnw.net/ttv-boxart/War%20of%20Angels-{width}x{height}.jpg","small":"http://static-cdn.jtvnw.net/ttv-boxart/War%20of%20Angels-52x72.jpg","medium":"http://static-cdn.jtvnw.net/ttv-boxart/War%20of%20Angels-136x190.jpg","large":"http://static-cdn.jtvnw.net/ttv-boxart/War%20of%20Angels-272x380.jpg"},"logoArt":{"template":"http://static-cdn.jtvnw.net/ttv-logoart/War%20of%20Angels-{width}x{height}.jpg","small":"http://static-cdn.jtvnw.net/ttv-logoart/War%20of%20Angels-60x36.jpg","medium":"http://static-cdn.jtvnw.net/ttv-logoart/War%20of%20Angels-120x72.jpg","large":"http://static-cdn.jtvnw.net/ttv-logoart/War%20of%20Angels-240x144.jpg"}},{"name":"War Inc.","id":9126,"giantbombId":9955,"images":{},"popularity":null,"boxArt":{"template":"http://static-cdn.jtvnw.net/ttv-boxart/War%20Inc.-{width}x{height}.jpg","small":"http://static-cdn.jtvnw.net/ttv-boxart/War%20Inc.-52x72.jpg","medium":"http://static-cdn.jtvnw.net/ttv-boxart/War%20Inc.-136x190.jpg","large":"http://static-cdn.jtvnw.net/ttv-boxart/War%20Inc.-272x380.jpg"},"logoArt":{"template":"http://static-cdn.jtvnw.net/ttv-logoart/War%20Inc.-{width}x{height}.jpg","small":"http://static-cdn.jtvnw.net/ttv-logoart/War%20Inc.-60x36.jpg","medium":"http://static-cdn.jtvnw.net/ttv-logoart/War%20Inc.-120x72.jpg","large":"http://static-cdn.jtvnw.net/ttv-logoart/War%20Inc.-240x144.jpg"}}] if (OnGameList != null) { OnGameList(this, EventArgs.Empty); } } }
public void ListTest() { var simplelist = new List<object>(); object item1 = new object(); object item2 = new object(); object item3 = new object(); object item4NotContains = new object(); simplelist.Add(item1); simplelist.Add(item2); simplelist.Add(item3); var gameList = new GameList<object>(); foreach (object o in simplelist) { gameList.Add(o); } foreach (object o in gameList) { Assert.IsTrue(simplelist.Contains(o)); } foreach (object o in simplelist) { Assert.IsTrue(gameList.Contains(o)); } Assert.IsFalse(gameList.Contains(item4NotContains)); Assert.AreEqual(gameList.Count, 3); gameList.Remove(x => ReferenceEquals(x, item2)); Assert.IsFalse(gameList.Contains(item2)); Assert.AreEqual(gameList.Count, 2); gameList.Clear(); Assert.AreEqual(gameList.Count, 0); }
private async void UpdateGameListAsync() { updateGameListWorking = true; var task = SteamServiceExt.GetOwnedGamesAsync(steamList.SteamID); await task.ContinueWith((result) => { //After web response is received, continue here var newList = result.Result.Games; var itemsTasks = 0; var itemsAdded = 0; object itemsLock = new object(); var comparator = new AlphabeticComparer(); //Start adding games to the game list lock (itemsLock) { foreach (Game item in newList) { // If item is in another list already, don't add it if (ignoreList.BinarySearch(item, comparator) < 0) { itemsTasks++; Application.Current.Dispatcher.BeginInvoke((ThreadStart) delegate { bool added = false; lock (gameList) { if (gameList.Count == 0) { gameList.Add(item); GameList.Add(item); OnPropertyChanged("GameList"); added = true; } if (comparator.Compare(gameList[gameList.Count - 1], item) < 0) { gameList.Add(item); GameList.Add(item); OnPropertyChanged("GameList"); added = true; } if (comparator.Compare(gameList[0], item) > 0) { gameList.Insert(0, item); GameList.Insert(0, item); OnPropertyChanged("GameList"); added = true; } int index = gameList.BinarySearch(item, comparator); // If index is negative, item is not present in list. Positive index means item is present in the list. if (index < 0) { index = ~index; gameList.Insert(index, item); GameList.Insert(index, item); OnPropertyChanged("GameList"); added = true; } } lock (itemsLock) { itemsTasks--; if (added) { itemsAdded++; } } }); } } //Create thread to show message when all tasks are done new Thread(() => { bool finished = false; while (!finished) { Thread.Sleep(100); lock (itemsLock) { if (itemsTasks == 0) { FileService.SaveFile(steamList); MessageBox.Show(itemsAdded + " games added to game list"); updateGameListWorking = false; finished = true; } } } }).Start(); } }); return; }
public async Task <DataTable> GetMatchedGameDetails(List <int> matchedGamesList) { ServicePointManager.DefaultConnectionLimit = 12; ServicePointManager.Expect100Continue = false; //WebClient bungie = new WebClient(); //accesses bungie.net HttpClient bungie = new HttpClient(); int sigStartPos; //beginning of desired substring int sigEndPos; //end of desired substring int failedPages = 0; //keep track of tasks that fail to download int successfulPages = 0; string result; //set Accept headers //bungie.DefaultRequestHeaders.TryAddWithoutValidation("Accept", "text/html,application/xhtml+xml,application/xml,application/json"); //set User agent //bungie.DefaultRequestHeaders.TryAddWithoutValidation("User-Agent", "Mozilla/5.0 (Windows NT 6.3; WOW64; Trident/7.0; EN; rv:11.0) like Gecko"); //bungie.DefaultRequestHeaders.TryAddWithoutValidation("Accept-Charset", "ISO-8859-1"); string gameType, map, playlist, dateText, gidString; int gid; string gameURL = "http://halo.bungie.net/Stats/GameStatsHalo3.aspx?gameid="; List <Task <string> > tasks = new List <Task <string> >(); List <string> debugTasks = new List <string>(); //for (int i = 0; i < 400; i++) //{ // Uri siteLink = new Uri(gameURL + matchedGamesList[i]); //GT = name of player, passed to method. // //creates url like // // // tasks.Add(bungie.GetStringAsync(siteLink)); // debugTasks.Add(tasks.Last().Id.ToString() + " " + siteLink.ToString()); //} foreach (int id in matchedGamesList) { Uri siteLink = new Uri(gameURL + id); //GT = name of player, passed to method. //creates url like // tasks.Add(bungie.GetStringAsync(siteLink)); debugTasks.Add(tasks.Last().Id.ToString() + " " + siteLink.ToString()); } while (tasks.Count > 0) { var taskComplete = await Task.WhenAny(tasks); tasks.Remove(taskComplete); try { result = taskComplete.Result; } catch { failedPages++; //Task.FromException(e); taskComplete.Dispose(); continue; //if try fails, means task failed to download string. skip task } //tasks.Remove(taskComplete); successfulPages++; try { //get gameID sigStartPos = result.IndexOf("gameid=") + ("gameid=").Length; sigEndPos = result.IndexOf("\"", sigStartPos); gidString = result.Substring(sigStartPos, sigEndPos - sigStartPos); gid = int.Parse(gidString); //to match up with SQL db datatype //get gametype sigStartPos = result.IndexOf("\"first styled\">") + ("\"first styled\">").Length; //index of first substring in HTML line that gives you gametype sigEndPos = result.IndexOf(" on ", sigStartPos); //index of next char after gametype gameType = result.Substring(sigStartPos, sigEndPos - sigStartPos); //works //get map //sigEndPos + 4 for " on " map = result.Substring(sigEndPos + 4, result.IndexOf("</li>", sigEndPos) - (sigEndPos + 4)); //works //get playlist sigStartPos = result.IndexOf("Playlist - ", sigEndPos) + ("Playlist - ").Length; sigEndPos = result.IndexOf(" </li>", sigStartPos); playlist = result.Substring(sigStartPos, sigEndPos - sigStartPos); //works //get dateText sigStartPos = result.IndexOf("<li>", sigEndPos + (" </ li >").Length) + ("<li>").Length; sigEndPos = result.IndexOf(",", sigStartPos); dateText = result.Substring(sigStartPos, sigEndPos - sigStartPos); } catch //gameID wasn't found, dispose the webClient and go to next item in list { continue; } GameList.Add(new Game(gid, dateText, map, gameType, playlist)); //detailTable.Rows.Add(gid, map, playlist, gameType, dateText); //add to data table for quicker storage in DB sigStartPos = 0; sigEndPos = 0; } return(new DataTable()); }