コード例 #1
0
        public static void LoadP2rBlocks(Event @event, IElement propsElement)
        {
            var elements = propsElement.QuerySelectorAll("tr > td.p2r");

            var length = elements.Length;

            for (var i = 0; i < length; i++)
            {
                var element = elements[i];
                var name    = element.QuerySelector("i.p2r").Text().Trim(':');

                var betBlock = new BetBlock(name, @event);

                var outcomeElements = element.QuerySelectorAll("u > a");

                foreach (var outcomeElement in outcomeElements)
                {
                    if (outcomeElement.Parent.PreviousSibling.NodeType == NodeType.Text)
                    {
                        var outcome = BlocksParserHelper.CreateOutcome(outcomeElement);
                        outcome.SetName(outcomeElement.Parent.PreviousSibling.Text());
                        betBlock.AddOutcome(outcome);
                    }
                }

                if (betBlock.Outcomes.Any())
                {
                    @event.BetBlocks.Add(betBlock);
                }
            }
        }
コード例 #2
0
        public static void LoadBlocksByHeader(Event @event, IElement element, string[] eventHeaderNames)
        {
            var elements = element.QuerySelectorAll("tr.bk");

            var periodName = string.Empty;

            for (var i = 0; i < elements.Length; i++)
            {
                var betElements = BlocksParserHelper.GetBetElements(elements[i]);

                var name = betElements[EVENT_COLUMN_NAME_INDEX].Text().Trim();

                if (!string.IsNullOrEmpty(name))
                {
                    periodName = name.Trim('.', ':');
                }

                var betBlock = new BetBlock("Main Bets", @event)
                {
                    PriodName = periodName
                };

                LoadBlockByHeader(betBlock, betElements, eventHeaderNames);

                if (betBlock.Outcomes.Any())
                {
                    @event.BetBlocks.Add(betBlock);
                }
            }
        }
コード例 #3
0
        public static void LoadPsBlocks(Event @event, IElement propsElement)
        {
            var psElements = propsElement.QuerySelectorAll("tr > td > table.ps > tbody > tr.btb");

            var length = psElements.Length;

            for (var i = 0; i < length; i++)
            {
                var psElement = psElements[i];
                var blockName = psElement.QuerySelector("th").Text().Trim(':');

                var betBlock = new BetBlock(blockName, @event);

                var betElements = psElement.NextElementSibling.QuerySelector("tr > td > table.ps > tbody");

                foreach (var betElement in betElements.Children)
                {
                    var name = betElement.QuerySelector("td > i")?.Text().Trim();

                    var outcomeElements = betElement.QuerySelectorAll("u > a");

                    decimal?param = null;
                    foreach (var outcomeElement in outcomeElements)
                    {
                        if (outcomeElement.Parent.PreviousSibling.NodeType == NodeType.Text)
                        {
                            var outcomeName = outcomeElement.Parent.PreviousSibling.Text().Trim(',', ' ', ';');

                            var match = PsBlockRegex.Match(outcomeName);

                            if (match.Success)
                            {
                                var outcome = BlocksParserHelper.CreateOutcome(outcomeElement);
                                outcome.Param = match.Groups["param"].ToNullDecimal();

                                if (param.HasValue && !outcome.Param.HasValue)
                                {
                                    outcome.Param = param;
                                }
                                else
                                {
                                    param = outcome.Param;
                                }


                                outcome.SetName($"{name}{match.Groups["name"].Value}");

                                betBlock.AddOutcome(outcome);
                            }
                        }
                    }
                }

                if (betBlock.Outcomes.Any())
                {
                    @event.BetBlocks.Add(betBlock);
                }
            }
        }
コード例 #4
0
        public static void LoadBlockByHeader(BetBlock betBlock, IElement[] betElements, string[] eventHeaderNames)
        {
            if (betElements.Length != eventHeaderNames.Length)
            {
                return;
            }

            for (var i = 0; i < eventHeaderNames.Length; i++)
            {
                var outcomes = betElements[i]?.QuerySelectorAll("u > a");

                if (outcomes == null || outcomes.Length == 0)
                {
                    continue;
                }

                var headerName = eventHeaderNames[i];

                int       offset;
                decimal[] outcomeParams = null;
                if (OutcomeOffset.TryGetValue(headerName, out offset))
                {
                    headerName    = $"{eventHeaderNames[i + offset]}{headerName}";
                    outcomeParams = BlocksParserHelper.GetOutcomeParams(betElements[i + offset]);
                }

                if (outcomeParams != null && outcomeParams.Length != outcomes.Length)
                {
                    continue;
                }

                for (var o = 0; o < outcomes.Length; o++)
                {
                    var outcomeElement = outcomes[o];

                    var outcome = BlocksParserHelper.CreateOutcome(outcomeElement);

                    outcome.SetName(outcomes.Length > 1 ? $"{headerName}{o + 1}" : headerName);

                    outcome.Param = outcomeParams?[o];

                    betBlock.AddOutcome(outcome);
                }
            }
        }
コード例 #5
0
        public static void LoadDinBlocks(Event @event, IElement propsElement)
        {
            var elements = propsElement.QuerySelectorAll("tr > td.dyn");

            var length = elements.Length;

            for (var i = 0; i < length; i++)
            {
                var element = elements[i];
                var name    = element.QuerySelector("i.p2r").Text().Trim(':');

                var betBlock = new BetBlock(name, @event);

                BlocksParserHelper.LoadNobrs(betBlock, element);

                if (betBlock.Outcomes.Any())
                {
                    @event.BetBlocks.Add(betBlock);
                }
            }
        }