コード例 #1
0
        /// <summary>
        /// Gets the new <see cref="IMarketWithOdds"/> instance
        /// </summary>
        /// <param name="sportEvent">A <see cref="ISportEvent"/> representing the sport event associated with the generated message</param>
        /// <param name="marketOddsChange">The <see cref="oddsChangeMarket"/> instance used</param>
        /// <param name="producerId">A producerId of the <see cref="ISportEvent"/></param>
        /// <param name="sportId">A sportId of the <see cref="ISportEvent"/></param>
        /// <param name="cultures">The list of cultures that should be prefetched</param>
        /// <returns>Returns the new <see cref="IMarketWithOdds"/> instance</returns>
        protected virtual IMarketWithOdds GetMarketWithOdds(ISportEvent sportEvent, oddsChangeMarket marketOddsChange, int producerId, URN sportId, IEnumerable <CultureInfo> cultures)
        {
            var cultureInfos = cultures.ToList();
            var specifiers   = string.IsNullOrEmpty(marketOddsChange.specifiers)
                ? null
                : FeedMapperHelper.GetSpecifiers(marketOddsChange.specifiers);

            var additionalInfo = string.IsNullOrEmpty(marketOddsChange.extended_specifiers)
                ? null
                : FeedMapperHelper.GetSpecifiers(marketOddsChange.extended_specifiers);

            var marketMetadata = marketOddsChange.market_metadata == null ||
                                 !marketOddsChange.market_metadata.next_betstopSpecified
                ? new MarketMetadata(null)
                : new MarketMetadata(marketOddsChange.market_metadata.next_betstop);

            var producer = _producerManager.Get(producerId);

            var nameProvider    = _nameProviderFactory.BuildNameProvider(sportEvent, marketOddsChange.id, specifiers);
            var mappingProvider = _mappingProviderFactory.BuildMarketMappingProvider(sportEvent, marketOddsChange.id, specifiers, _producerManager.Get(producerId), sportId);

            return(new MarketWithOdds(
                       marketOddsChange.id,
                       specifiers,
                       additionalInfo,
                       nameProvider,
                       mappingProvider,
                       MessageMapperHelper.GetEnumValue <MarketStatus>(marketOddsChange.status),
                       marketOddsChange.cashout_statusSpecified ? (CashoutStatus?)MessageMapperHelper.GetEnumValue <CashoutStatus>(marketOddsChange.cashout_status) : null,
                       marketOddsChange.favouriteSpecified && marketOddsChange.favourite == 1,
                       marketOddsChange.outcome?.Select(o => GetOutcomeWithOdds(sportEvent, nameProvider, mappingProvider, o, cultureInfos, BuildOutcomeDefinition(marketOddsChange.id, sportId, producer, specifiers, o.id, cultureInfos))),
                       marketMetadata,
                       BuildMarketDefinition(marketOddsChange.id, sportId, producer, specifiers, cultureInfos),
                       cultureInfos));
        }
コード例 #2
0
        /// <summary>
        /// Gets the new <see cref="IMarketWithOdds"/> instance
        /// </summary>
        /// <param name="sportEvent">A <see cref="ISportEvent"/> representing the sport event associated with the generated message</param>
        /// <param name="marketOddsChange">The <see cref="oddsChangeMarket"/> instance used</param>
        /// <param name="producerId">A producerId of the <see cref="ISportEvent"/></param>
        /// <param name="sportId">A sportId of the <see cref="ISportEvent"/></param>
        /// <param name="cultures">The list of cultures that should be prefetched</param>
        /// <returns>Returns the new <see cref="IMarketWithOdds"/> instance</returns>
        protected virtual IMarketWithOdds GetMarketWithOdds(ISportEvent sportEvent, oddsChangeMarket marketOddsChange, int producerId, URN sportId, IEnumerable <CultureInfo> cultures)
        {
            var cultureInfos = cultures.ToList();
            var specifiers   = string.IsNullOrEmpty(marketOddsChange.specifiers)
                ? null
                : FeedMapperHelper.GetSpecifiers(marketOddsChange.specifiers);

            var additionalInfo = string.IsNullOrEmpty(marketOddsChange.extended_specifiers)
                ? null
                : FeedMapperHelper.GetSpecifiers(marketOddsChange.extended_specifiers);

            var marketMetadata = new MarketMetadata(marketOddsChange.market_metadata);

            var nameProvider    = _nameProviderFactory.BuildNameProvider(sportEvent, marketOddsChange.id, specifiers);
            var mappingProvider = _mappingProviderFactory.BuildMarketMappingProvider(sportEvent, marketOddsChange.id, specifiers, producerId, sportId);

            var outcomes = marketOddsChange.outcome?.Select(outcome =>
                                                            GetOutcomeWithOdds(sportEvent,
                                                                               nameProvider,
                                                                               mappingProvider,
                                                                               outcome,
                                                                               cultureInfos,
                                                                               new OutcomeDefinition(marketOddsChange.id, outcome.id, _marketCacheProvider, specifiers, cultureInfos, _externalExceptionStrategy)));

            var marketDefinition = new MarketDefinition(marketOddsChange.id, _marketCacheProvider, sportId, producerId, specifiers, cultureInfos, _externalExceptionStrategy);

            return(new MarketWithOdds(marketOddsChange.id,
                                      specifiers,
                                      additionalInfo,
                                      nameProvider,
                                      mappingProvider,
                                      MessageMapperHelper.GetEnumValue <MarketStatus>(marketOddsChange.status),
                                      marketOddsChange.cashout_statusSpecified ? (CashoutStatus?)MessageMapperHelper.GetEnumValue <CashoutStatus>(marketOddsChange.cashout_status) : null,
                                      marketOddsChange.favouriteSpecified && marketOddsChange.favourite == 1,
                                      outcomes,
                                      marketMetadata,
                                      marketDefinition,
                                      cultureInfos));
        }
コード例 #3
0
        private void TestMarketValues(IMarketWithOdds entity, oddsChangeMarket record)
        {
            Assert.AreEqual(entity.Id, record.id, "Market id is not correct");
            Assert.IsTrue(CompareSpecifiers(entity.Specifiers, record.specifiers), "The market specifiers do not match");
            Assert.IsTrue(CompareSpecifiers(entity.AdditionalInfo, record.extended_specifiers), "Market additional specifiers do not match");
            Assert.AreEqual(entity.CashoutStatus, record.cashout_statusSpecified ? (CashoutStatus?)MessageMapperHelper.GetEnumValue <CashoutStatus>(record.cashout_status) : null, $"Market id={entity.Id} cashout status do not match");
            Assert.AreEqual(entity.IsFavorite, record.favouriteSpecified && record.favourite == 1, $"Market id={entity.Id} favorite does not match");
            Assert.AreEqual(entity.Status, MessageMapperHelper.GetEnumValue <MarketStatus>(record.status), $"Market id={entity.Id} status does not match");


            if (record.outcome == null || record.outcome.Length == 0)
            {
                Assert.IsNull(entity.OutcomeOdds);
            }
            else
            {
                foreach (var outcomeRecord in record.outcome)
                {
                    var outcome = FindOutcome(entity.OutcomeOdds, outcomeRecord.id);
                    Assert.IsNotNull(outcome, $"Outcome marketId={entity.Id} id={outcomeRecord.id} does not exist");
                    TestOutcomeValues(outcome, outcomeRecord);
                }
            }
        }
コード例 #4
0
        /// <summary>
        /// Gets the new <see cref="IMarketWithProbabilities"/> instance
        /// </summary>
        /// <param name="sportEvent">A <see cref="ISportEvent"/> representing the sport event associated with the generated message</param>
        /// <param name="marketOddsChange">The <see cref="oddsChangeMarket"/> instance used</param>
        /// <param name="producerId">A producerId specifying message producer</param>
        /// <param name="sportId">A sportId of the <see cref="ISportEvent"/></param>
        /// <param name="cultures">The list of cultures that should be prefetched</param>
        /// <returns>Returns the new <see cref="IMarketWithOdds"/> instance</returns>
        protected virtual IMarketWithProbabilities GetMarketWithProbabilities(ISportEvent sportEvent, oddsChangeMarket marketOddsChange, int producerId, URN sportId, IEnumerable <CultureInfo> cultures)
        {
            var cultureInfos = cultures.ToList();
            var specifiers   = string.IsNullOrEmpty(marketOddsChange.specifiers)
                ? null
                : FeedMapperHelper.GetSpecifiers(marketOddsChange.specifiers);

            var additionalInfo = string.IsNullOrEmpty(marketOddsChange.extended_specifiers)
                ? null
                : FeedMapperHelper.GetSpecifiers(marketOddsChange.extended_specifiers);

            var producer = _producerManager.Get(producerId);

            var nameProvider    = _nameProviderFactory.BuildNameProvider(sportEvent, marketOddsChange.id, specifiers);
            var mappingProvider = _mappingProviderFactory.BuildMarketMappingProvider(sportEvent, marketOddsChange.id, specifiers, _producerManager.Get(producerId), sportId);

            return(new MarketWithProbabilities(
                       marketOddsChange.id,
                       specifiers,
                       additionalInfo,
                       nameProvider,
                       mappingProvider,
                       MessageMapperHelper.GetEnumValue <MarketStatus>(marketOddsChange.status),
                       marketOddsChange.outcome?.Select(outcomeOdds => new OutcomeProbabilities(
                                                            outcomeOdds.id,
                                                            outcomeOdds.activeSpecified
                                                                                                                            ? (bool?)(outcomeOdds.active != 0)
                                                                                                                            : null,
                                                            outcomeOdds.probabilitiesSpecified
                                                                                                                            ? (double?)outcomeOdds.probabilities
                                                                                                                            : null,
                                                            nameProvider,
                                                            mappingProvider,
                                                            cultureInfos,
                                                            BuildOutcomeDefinition(marketOddsChange.id, sportId, producer, specifiers, outcomeOdds.id, cultureInfos))),
                       BuildMarketDefinition(marketOddsChange.id, sportId, producer, specifiers, cultureInfos),
                       cultureInfos));
        }
コード例 #5
0
        private static ValidationResult ValidateOddsChangeOutcomes(FeedMessage message, oddsChangeMarket market, oddsChangeMarketOutcome outcome, ValidationResult currentResult)
        {
            if (outcome.activeSpecified && (outcome.active < 0 || outcome.active > 1))
            {
                LogWarning(message, $"markets[{market.id}].outcomes[{outcome.id}].active", outcome.active);
                currentResult = ValidationResult.PROBLEMS_DETECTED;
            }

            if (outcome.teamSpecified)
            {
                if (message.EventURN.TypeGroup != ResourceTypeGroup.MATCH)
                {
                    LogWarning(message, $"Player outcome=[marketId={market.id}, outcomeId={outcome.id}] cannot be mapped to IPlayerOutcomeOdds because associated event[id={message.EventURN}] is not an match", outcome.team);
                    currentResult = ValidationResult.PROBLEMS_DETECTED;
                }

                if (outcome.team < 1 || outcome.team > 2)
                {
                    LogWarning(message, $"Player outcome=[marketId={market.id}, outcomeId={outcome.id}] cannot be mapped to IPlayerOutcomeOdds because team attribute value {outcome.team} is out of range", outcome.team);
                    currentResult = ValidationResult.PROBLEMS_DETECTED;
                }
            }
            return(currentResult);
        }
コード例 #6
0
        /// <summary>
        /// Gets the new <see cref="IMarketWithProbabilities"/> instance
        /// </summary>
        /// <param name="sportEvent">A <see cref="ISportEvent"/> representing the sport event associated with the generated message</param>
        /// <param name="marketOddsChange">The <see cref="oddsChangeMarket"/> instance used</param>
        /// <param name="producerId">A producerId specifying message producer</param>
        /// <param name="sportId">A sportId of the <see cref="ISportEvent"/></param>
        /// <param name="cultures">The list of cultures that should be prefetched</param>
        /// <returns>Returns the new <see cref="IMarketWithOdds"/> instance</returns>
        protected virtual IMarketWithProbabilities GetMarketWithProbabilities(ISportEvent sportEvent, oddsChangeMarket marketOddsChange, int producerId, URN sportId, IEnumerable <CultureInfo> cultures)
        {
            var cultureInfos = cultures.ToList();
            var specifiers   = string.IsNullOrEmpty(marketOddsChange.specifiers)
                ? null
                : FeedMapperHelper.GetSpecifiers(marketOddsChange.specifiers);

            var additionalInfo = string.IsNullOrEmpty(marketOddsChange.extended_specifiers)
                ? null
                : FeedMapperHelper.GetSpecifiers(marketOddsChange.extended_specifiers);

            var nameProvider    = _nameProviderFactory.BuildNameProvider(sportEvent, marketOddsChange.id, specifiers);
            var mappingProvider = _mappingProviderFactory.BuildMarketMappingProvider(sportEvent, marketOddsChange.id, specifiers, producerId, sportId);

            var marketDefinition = new MarketDefinition(marketOddsChange.id, _marketCacheProvider, sportId, producerId, specifiers, cultureInfos, _externalExceptionStrategy);

            return(new MarketWithProbabilities(marketOddsChange.id,
                                               specifiers,
                                               additionalInfo,
                                               nameProvider,
                                               mappingProvider,
                                               MessageMapperHelper.GetEnumValue <MarketStatus>(marketOddsChange.status),
                                               marketOddsChange.outcome?.Select(outcomeOdds =>
                                                                                new OutcomeProbabilities(outcomeOdds.id,
                                                                                                         outcomeOdds.activeSpecified ? (bool?)(outcomeOdds.active != 0) : null,
                                                                                                         outcomeOdds.probabilitiesSpecified ? (double?)outcomeOdds.probabilities : null,
                                                                                                         nameProvider,
                                                                                                         mappingProvider,
                                                                                                         cultureInfos,
                                                                                                         new OutcomeDefinition(marketOddsChange.id, outcomeOdds.id, _marketCacheProvider, specifiers, cultureInfos, _externalExceptionStrategy),
                                                                                                         GetAdditionalProbabilities(outcomeOdds))),
                                               marketDefinition,
                                               cultureInfos,
                                               marketOddsChange.cashout_statusSpecified ? (CashoutStatus?)MessageMapperHelper.GetEnumValue <CashoutStatus>(marketOddsChange.cashout_status) : null,
                                               GetMarketMetadata(marketOddsChange.market_metadata)));
        }