internal IEnumerable <IMatchExtended> GetMatchesFromPlayer(string playerId, PlayerMatchesOptions playerMatchesOptions) { HtmlNode root = mainController.HtmlDocumentController.GetDotabuffPlayerMatchesRoot(playerId, playerMatchesOptions); List <IMatchExtended> playerMatches = new List <IMatchExtended>(); MatchPath machPath = new MatchPath { Duration = PlayerMatchesPath.Duration.Value, Hero = PlayerMatchesPath.Hero.Value, Id = PlayerMatchesPath.Id.Value, Kda = PlayerMatchesPath.Kda.Value, Mode = PlayerMatchesPath.Mode.Value, Result = PlayerMatchesPath.Result.Value, Skillbracket = PlayerMatchesPath.Skillbracket.Value, TimeAgo = PlayerMatchesPath.TimeAgo.Value, Type = PlayerMatchesPath.Type.Value, IdAttribute = HtmlAttributes.PlayerMatches.Attribute.Value, IdReplace = HtmlAttributes.PlayerMatches.Replace.Value, }; int counter = 1; IEnumerable <HtmlNode> matchesNodes = root.SelectNodes(PlayerMatchesPath.Table.Value); if (matchesNodes != null) { foreach (HtmlNode matchNode in matchesNodes) { Match match = matchController.MapHtmlNodeToMatch(root, machPath, counter); List <IItem> items = new List <IItem>(); IEnumerable <HtmlNode> itemNodes = root.SelectNodes(mainController.CombinePathWithListCount(PlayerMatchesPath.Items.Value, counter)); if (itemNodes != null) { foreach (HtmlNode itemNode in itemNodes) { string itemReference = itemNode.Attributes[HtmlAttributes.Item.Attribute.Value].Value.Replace( HtmlAttributes.Item.Replace.Value, ""); items.Add(mainController.ItemController.GetItem(itemReference)); } } match.Items = items; playerMatches.Add(match); counter++; } } return(playerMatches); }
internal HtmlNode GetDotabuffPlayerMatchesRoot(string playerId, PlayerMatchesOptions playerMatchesOptions) { return(LoadDocumentNode(string.Format(DotabuffUrlPath.Players.Matches.URL.Value + mainController.QueryStringController.GetQueryString(playerMatchesOptions), playerId))); }