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));
 }
示例#3
0
 /// <summary>
 /// Gathers all the matches from the Dotabuff PlayerMatches-Page and combines it into list of matches.
 /// </summary>
 /// <param name="playerId">The Player Id (not the Steam Id)</param>
 /// <param name="playerMatchesOptions">Options for selecting the Player Matches</param>
 /// <returns>Will return all matches that match the criteria of the options</returns>
 public IEnumerable<IMatchExtended> GetPlayerMatchesPageData(string playerId, PlayerMatchesOptions playerMatchesOptions)
 {
     try
     {
         return mainController.PlayerController.GetMatchesFromPlayer(playerId, playerMatchesOptions);
     }
     catch (Exception exception)
     {
         throw new Dota2StatParserException("Something went wrong while parsing the player matches. See the innerexception for details!", exception);
     }
 }