/// <summary>
        /// Initializes a new instance of the <see cref="MarketWithOdds"/> class
        /// </summary>
        /// <param name="id">a <see cref="int"/> value specifying the market type</param>
        /// <param name="specifiers">a <see cref="IReadOnlyDictionary{String, String}"/> containing market specifiers.</param>
        /// <param name="additionalInfo">a <see cref="IReadOnlyDictionary{String, String}"/> containing additional market info.</param>
        /// <param name="nameProvider">A <see cref="INameProvider"/> instance used to generate the market name(s) </param>
        /// <param name="mappingProvider">A <see cref="IMarketMappingProvider"/> instance used for providing mapped ids of markets and outcomes</param>
        /// <param name="status">a <see cref="MarketStatus"/> enum member specifying the status of the market associated with the current <see cref="IMarketWithOdds"/> instance</param>
        /// <param name="cashoutStatus">A <see cref="CashoutStatus"/> to be set</param>
        /// <param name="isFavorite">Gets a value indicating whether the market associated with the current <see cref="IMarketWithOdds"/> instance is the most
        ///     balanced market.</param>
        /// <param name="outcomeOdds">a <see cref="IEnumerable{IOutcomeOdds}"/> where each <see cref="IOutcomeOdds"/> instance specifies the odds
        ///     for one outcome associated with the current <see cref="IMarketWithOdds"/> instance</param>
        /// <param name="marketMetadata">A <see cref="IMarketMetadata"/> to be set</param>
        /// <param name="marketDefinition">The associated market definition</param>
        /// <param name="cultures">A <see cref="IEnumerable{CultureInfo}"/> specifying languages the current instance supports</param>
        internal MarketWithOdds(int id,
                                IReadOnlyDictionary <string, string> specifiers,
                                IReadOnlyDictionary <string, string> additionalInfo,
                                INameProvider nameProvider,
                                IMarketMappingProvider mappingProvider,
                                MarketStatus status,
                                CashoutStatus?cashoutStatus,
                                bool isFavorite,
                                IEnumerable <IOutcomeOdds> outcomeOdds,
                                IMarketMetadata marketMetadata,
                                IMarketDefinition marketDefinition,
                                IEnumerable <CultureInfo> cultures)
            : base(id, specifiers, additionalInfo, nameProvider, mappingProvider, marketDefinition, cultures)
        {
            Status        = status;
            CashoutStatus = cashoutStatus;

            if (outcomeOdds != null)
            {
                OutcomeOdds = outcomeOdds as ReadOnlyCollection <IOutcomeOdds> ?? new ReadOnlyCollection <IOutcomeOdds>(outcomeOdds.ToList());
            }
            IsFavorite = isFavorite;

            MarketMetadata = marketMetadata;
        }
Esempio n. 2
0
        /// <summary>Initializes a new instance of the <see cref="OutcomeSettlement" /> class</summary>
        /// <param name="deadHeatFactor">a dead-head factor for the current <see cref="IOutcomeSettlement" /> instance.</param>
        /// <param name="id">the value uniquely identifying the current <see cref="IOutcomeSettlement" /></param>
        /// <param name="result">a value indicating whether the outcome associated with current <see cref="IOutcomeSettlement" /> is winning</param>
        /// <param name="voidFactor">the <see cref="VoidFactor" /> associated with a current <see cref="IOutcomeSettlement" /> or a null reference</param>
        /// <param name="nameProvider">A <see cref="INameProvider"/> used to generate the outcome name(s)</param>
        /// <param name="mappingProvider">A <see cref="IMarketMappingProvider"/> instance used for providing mapping ids of markets and outcomes</param>
        /// <param name="cultures">A <see cref="IEnumerable{CultureInfo}"/> specifying languages the current instance supports</param>
        /// <param name="outcomeDefinition">The associated <see cref="IOutcomeDefinition"/></param>
        internal OutcomeSettlement(double?deadHeatFactor,
                                   string id,
                                   int result,
                                   VoidFactor?voidFactor,
                                   INameProvider nameProvider,
                                   IMarketMappingProvider mappingProvider,
                                   IEnumerable <CultureInfo> cultures,
                                   IOutcomeDefinition outcomeDefinition)
            : base(id, nameProvider, mappingProvider, cultures, outcomeDefinition)
        {
            DeadHeatFactor = deadHeatFactor;
            Result         = result == 1;
            VoidFactor     = voidFactor;
            switch (result)
            {
            case 0:
                OutcomeResult = OutcomeResult.Lost;
                break;

            case 1:
                OutcomeResult = OutcomeResult.Won;
                break;

            default:
                OutcomeResult = OutcomeResult.UndecidedYet;
                break;
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Outcome" /> class
        /// </summary>
        /// <param name="id">the value uniquely identifying the current <see cref="Outcome" /> instance</param>
        /// <param name="nameProvider">A <see cref="INameProvider"/> used to generate the outcome name(s)</param>
        /// <param name="mappingProvider">A <see cref="IMarketMappingProvider"/> instance used for providing mapping ids of markets and outcomes</param>
        /// <param name="cultures">A <see cref="IEnumerable{CultureInfo}"/> specifying languages the current instance supports</param>
        /// <param name="outcomeDefinition"></param>
        protected Outcome(string id, INameProvider nameProvider, IMarketMappingProvider mappingProvider, IEnumerable <CultureInfo> cultures, IOutcomeDefinition outcomeDefinition)
        {
            Guard.Argument(nameProvider, nameof(nameProvider)).NotNull();
            Guard.Argument(cultures, nameof(cultures)).NotNull().NotEmpty();

            Id                = id;
            _nameProvider     = nameProvider;
            _mappingProvider  = mappingProvider;
            _cultures         = cultures;
            OutcomeDefinition = outcomeDefinition;
        }
Esempio n. 4
0
        /// <summary>
        ///     Initializes a new instance of the <see cref="Outcome" /> class
        /// </summary>
        /// <param name="id">the value uniquely identifying the current <see cref="Outcome" /> instance</param>
        /// <param name="nameProvider">A <see cref="INameProvider"/> used to generate the outcome name(s)</param>
        /// <param name="mappingProvider">A <see cref="IMarketMappingProvider"/> instance used for providing mapping ids of markets and outcomes</param>
        /// <param name="cultures">A <see cref="IEnumerable{CultureInfo}"/> specifying languages the current instance supports</param>
        /// <param name="outcomeDefinition"></param>
        protected Outcome(string id, INameProvider nameProvider, IMarketMappingProvider mappingProvider, IEnumerable <CultureInfo> cultures, IOutcomeDefinition outcomeDefinition)
        {
            Contract.Requires(nameProvider != null);
            Contract.Requires(cultures != null);
            Contract.Requires(cultures.Any());

            Id                = id;
            _nameProvider     = nameProvider;
            _mappingProvider  = mappingProvider;
            _cultures         = cultures;
            OutcomeDefinition = outcomeDefinition;
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="OutcomeOdds" /> class
 /// </summary>
 /// <param name="id">the value uniquely identifying the current <see cref="OutcomeOdds" /> instance</param>
 /// <param name="active">A value indicating whether the current <see cref="OutcomeOdds" /> is active - i.e. should bets on it be accepted </param>
 /// <param name="odds">the odds for the current <see cref="OutcomeOdds" /> instance</param>
 /// <param name="probabilities">the probabilities for the current <see cref="OutcomeOdds" /> instance</param>
 /// <param name="nameProvider">A <see cref="INameProvider"/> used to generate the outcome name(s)</param>
 /// <param name="mappingProvider">A <see cref="IMarketMappingProvider"/> instance used for providing mapping ids of markets and outcomes</param>
 /// <param name="cultures">A <see cref="IEnumerable{CultureInfo}"/> specifying languages the current instance supports</param>
 /// <param name="outcomeDefinition">The associated <see cref="IOutcomeDefinition"/></param>
 internal OutcomeOdds(string id,
                      bool?active,
                      double odds,
                      double?probabilities,
                      INameProvider nameProvider,
                      IMarketMappingProvider mappingProvider,
                      IEnumerable <CultureInfo> cultures,
                      IOutcomeDefinition outcomeDefinition)
     : base(id, active, probabilities, nameProvider, mappingProvider, cultures, outcomeDefinition)
 {
     Odds = odds;
 }
Esempio n. 6
0
 /// <summary>Initializes a new instance of the <see cref="OutcomeSettlement" /> class</summary>
 /// <param name="deadHeatFactor">a dead-head factor for the current <see cref="IOutcomeSettlement" /> instance.</param>
 /// <param name="id">the value uniquely identifying the current <see cref="IOutcomeSettlement" /></param>
 /// <param name="result">a value indicating whether the outcome associated with current <see cref="IOutcomeSettlement" /> is winning</param>
 /// <param name="voidFactor">the <see cref="VoidFactor" /> associated with a current <see cref="IOutcomeSettlement" /> or a null reference</param>
 /// <param name="nameProvider">A <see cref="INameProvider"/> used to generate the outcome name(s)</param>
 /// <param name="mappingProvider">A <see cref="IMarketMappingProvider"/> instance used for providing mapping ids of markets and outcomes</param>
 /// <param name="cultures">A <see cref="IEnumerable{CultureInfo}"/> specifying languages the current instance supports</param>
 /// <param name="outcomeDefinition">The associated <see cref="IOutcomeDefinition"/></param>
 internal OutcomeSettlement(double?deadHeatFactor,
                            string id,
                            bool result,
                            VoidFactor?voidFactor,
                            INameProvider nameProvider,
                            IMarketMappingProvider mappingProvider,
                            IEnumerable <CultureInfo> cultures,
                            IOutcomeDefinition outcomeDefinition)
     : base(id, nameProvider, mappingProvider, cultures, outcomeDefinition)
 {
     DeadHeatFactor = deadHeatFactor;
     Result         = result;
     VoidFactor     = voidFactor;
 }
 /// <summary>Initializes a new instance of the <see cref="OutcomeProbabilities" /> class</summary>
 /// <param name="id">The value uniquely identifying the current <see cref="OutcomeProbabilities" /> instance</param>
 /// <param name="active">A value indicating whether the current <see cref="OutcomeProbabilities" /> is active - i.e. should bets on it be accepted
 /// </param>
 /// <param name="probabilities">The probabilities for the current <see cref="OutcomeProbabilities" /> instance</param>
 /// <param name="nameProvider">A <see cref="INameProvider"/> used to generate the outcome name(s)</param>
 /// <param name="mappingProvider">A <see cref="IMarketMappingProvider"/> instance used for providing mapping ids of markets and outcomes</param>
 /// <param name="cultures">A <see cref="IEnumerable{CultureInfo}"/> specifying languages the current instance supports</param>
 /// <param name="outcomeDefinition">The associated <see cref="IOutcomeDefinition"/></param>
 /// <param name="additionalProbabilities">Additional probability attributes for markets which potentially will be (partly) refunded</param>
 internal OutcomeProbabilities(string id,
                               bool?active,
                               double?probabilities,
                               INameProvider nameProvider,
                               IMarketMappingProvider mappingProvider,
                               IEnumerable <CultureInfo> cultures,
                               IOutcomeDefinition outcomeDefinition,
                               IAdditionalProbabilities additionalProbabilities)
     : base(id, nameProvider, mappingProvider, cultures, outcomeDefinition)
 {
     Active                  = active;
     Probabilities           = probabilities;
     AdditionalProbabilities = additionalProbabilities;
 }
Esempio n. 8
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Outcome" /> class
        /// </summary>
        /// <param name="id">the value uniquely identifying the current <see cref="Outcome" /> instance</param>
        /// <param name="nameProvider">A <see cref="INameProvider"/> used to generate the outcome name(s)</param>
        /// <param name="mappingProvider">A <see cref="IMarketMappingProvider"/> instance used for providing mapping ids of markets and outcomes</param>
        /// <param name="cultures">A <see cref="IEnumerable{CultureInfo}"/> specifying languages the current instance supports</param>
        /// <param name="outcomeDefinition">An outcome definition</param>
        protected Outcome(string id, INameProvider nameProvider, IMarketMappingProvider mappingProvider, IEnumerable <CultureInfo> cultures, IOutcomeDefinition outcomeDefinition)
        {
            Guard.Argument(nameProvider, nameof(nameProvider)).NotNull();
            Guard.Argument(cultures, nameof(cultures)).NotNull();
            if (!cultures.Any())
            {
                throw new ArgumentOutOfRangeException(nameof(cultures));
            }

            Id                = id;
            _nameProvider     = nameProvider;
            _mappingProvider  = mappingProvider;
            _cultures         = cultures;
            OutcomeDefinition = outcomeDefinition;
        }
Esempio n. 9
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MarketWithSettlement" /> class
        /// </summary>
        /// <param name="id">a <see cref="int" /> value specifying the market type</param>
        /// <param name="specifiers">a <see cref="IReadOnlyDictionary{String, String}" /> containing additional market specifiers</param>
        /// <param name="additionalInfo">a <see cref="IReadOnlyDictionary{String, String}"/> containing additional market info</param>
        /// <param name="nameProvider">A <see cref="INameProvider"/> instance used to generate the market name(s)</param>
        /// <param name="mappingProvider">A <see cref="IMarketMappingProvider"/> instance used for providing mapped ids of markets and outcomes</param>
        /// <param name="marketDefinition">The associated market definition</param>
        /// <param name="voidReason">A value specifying the void reason or a null reference</param>
        /// <param name="voidReasonsCache">A <see cref="INamedValueCache"/> used to get void reason descriptions</param>
        /// <param name="cultures">A <see cref="IEnumerable{CultureInfo}"/> specifying languages the current instance supports</param>
        internal MarketCancel(int id,
                              IReadOnlyDictionary <string, string> specifiers,
                              IReadOnlyDictionary <string, string> additionalInfo,
                              INameProvider nameProvider,
                              IMarketMappingProvider mappingProvider,
                              IMarketDefinition marketDefinition,
                              int?voidReason,
                              INamedValueCache voidReasonsCache,
                              IEnumerable <CultureInfo> cultures)
            : base(id, specifiers, additionalInfo, nameProvider, mappingProvider, marketDefinition, cultures)
        {
            Guard.Argument(voidReasonsCache, nameof(voidReasonsCache)).NotNull();

            _voidReason       = voidReason;
            _voidReasonsCache = voidReasonsCache;
        }
Esempio n. 10
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MarketWithSettlement" /> class
        /// </summary>
        /// <param name="id">a <see cref="int" /> value specifying the market type</param>
        /// <param name="specifiers">a <see cref="IReadOnlyDictionary{String, String}" /> containing additional market specifiers</param>
        /// <param name="additionalInfo">a <see cref="IReadOnlyDictionary{String, String}"/> containing additional market info</param>
        /// <param name="nameProvider">A <see cref="INameProvider"/> instance used to generate the market name(s)</param>
        /// <param name="mappingProvider">A <see cref="IMarketMappingProvider"/> instance used for providing mapped ids of markets and outcomes</param>
        /// <param name="marketDefinition">The associated market definition</param>
        /// <param name="voidReason">A value specifying the void reason or a null reference</param>
        /// <param name="voidReasonsCache">A <see cref="INamedValueCache"/> used to get void reason descriptions</param>
        /// <param name="cultures">A <see cref="IEnumerable{CultureInfo}"/> specifying languages the current instance supports</param>
        internal MarketCancel(int id,
                              IReadOnlyDictionary <string, string> specifiers,
                              IReadOnlyDictionary <string, string> additionalInfo,
                              INameProvider nameProvider,
                              IMarketMappingProvider mappingProvider,
                              IMarketDefinition marketDefinition,
                              int?voidReason,
                              INamedValueCache voidReasonsCache,
                              IEnumerable <CultureInfo> cultures)
            : base(id, specifiers, additionalInfo, nameProvider, mappingProvider, marketDefinition, cultures)
        {
            Contract.Requires(voidReasonsCache != null);

            _voidReason       = voidReason;
            _voidReasonsCache = voidReasonsCache;
        }
        /// <summary>
        ///     Initializes a new instance of the <see cref="PlayerOutcomeOdds" /> class
        /// </summary>
        /// <param name="id">the value uniquely identifying the current <see cref="PlayerOutcomeOdds" /> instance</param>
        /// <param name="active">
        ///     a value indicating whether the current <see cref="OutcomeOdds" /> is active - i.e. should bets on
        ///     it be accepted
        /// </param>
        /// <param name="odds">the odds for the current <see cref="OutcomeOdds" /> instance</param>
        /// <param name="probabilities">the probabilities for the current <see cref="OutcomeOdds" /> instance</param>
        /// <param name="nameProvider">A <see cref="INameProvider"/> used to generate the outcome name(s)</param>
        /// <param name="mappingProvider">A <see cref="IMarketMappingProvider"/> instance used for providing mapping ids of markets and outcomes</param>
        /// <param name="match">A <see cref="IMatch"/> representing the the match associated with the outcome / market</param>
        /// <param name="teamFlag">A value indicating whether the player is associated with home or away team - 1 : HomeTeam, 2 : AwayTeam</param>
        /// <param name="cultures">A <see cref="IEnumerable{CultureInfo}"/> specifying languages the current instance supports</param>
        /// <param name="outcomeDefinition">The associated <see cref="IOutcomeDefinition"/></param>
        internal PlayerOutcomeOdds(string id,
                                   bool?active,
                                   double odds,
                                   double?probabilities,
                                   INameProvider nameProvider,
                                   IMarketMappingProvider mappingProvider,
                                   IMatch match,
                                   int teamFlag,
                                   IEnumerable <CultureInfo> cultures,
                                   IOutcomeDefinition outcomeDefinition)
            : base(id, active, odds, probabilities, nameProvider, mappingProvider, cultures, outcomeDefinition)
        {
            Contract.Requires(match != null);
            Contract.Requires(teamFlag >= 1 && teamFlag <= 2);

            _teamFlag = teamFlag;
            _match    = match;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="MarketWithProbabilities"/> class
        /// </summary>
        /// <param name="id">a <see cref="int"/> value specifying the market type</param>
        /// <param name="specifiers">a <see cref="IReadOnlyDictionary{String, String}"/> containing market specifiers.</param>
        /// <param name="additionalInfo">a <see cref="IReadOnlyDictionary{String, String}"/> containing additional market info.</param>
        /// <param name="nameProvider">A <see cref="INameProvider"/> instance used to generate the market name(s) </param>
        /// <param name="mappingProvider">A <see cref="IMarketMappingProvider"/> instance used for providing mapped ids of markets and outcomes</param>
        /// <param name="status">a <see cref="MarketStatus"/> enum member specifying the status of the market associated with the current <see cref="IMarketWithProbabilities"/> instance</param>
        /// <param name="outcomeProbabilities">a <see cref="IEnumerable{IOutcomeProbabilities}"/> where each <see cref="IOutcomeProbabilities"/> instance specifies the odds
        /// for one outcome associated with the current <see cref="IMarketWithProbabilities"/> instance</param>
        /// <param name="marketDefinition">The associated market definition</param>
        /// <param name="cultures">A <see cref="IEnumerable{CultureInfo}"/> specifying languages the current instance supports</param>
        internal MarketWithProbabilities(int id,
                                         IReadOnlyDictionary <string, string> specifiers,
                                         IReadOnlyDictionary <string, string> additionalInfo,
                                         INameProvider nameProvider,
                                         IMarketMappingProvider mappingProvider,
                                         MarketStatus status,
                                         IEnumerable <IOutcomeProbabilities> outcomeProbabilities,
                                         IMarketDefinition marketDefinition,
                                         IEnumerable <CultureInfo> cultures)
            : base(id, specifiers, additionalInfo, nameProvider, mappingProvider, marketDefinition, cultures)
        {
            Status = status;

            if (outcomeProbabilities != null)
            {
                OutcomeProbabilities = outcomeProbabilities as ReadOnlyCollection <IOutcomeProbabilities> ?? new ReadOnlyCollection <IOutcomeProbabilities>(outcomeProbabilities.ToList());
            }
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="MarketWithSettlement" /> class
        /// </summary>
        /// <param name="id">a <see cref="int" /> value specifying the market type</param>
        /// <param name="specifiers">a <see cref="IReadOnlyDictionary{String, String}" /> containing additional market specifiers</param>
        /// <param name="additionalInfo">a <see cref="IReadOnlyDictionary{String, String}"/> containing additional market info</param>
        /// <param name="outcomes">An <see cref="IEnumerable{IOutcomeSettlement}" /> where each <see cref="IOutcomeSettlement" /> instance providing outcome settling information
        /// </param>
        /// <param name="nameProvider">A <see cref="INameProvider"/> instance used to generate the market name(s)</param>
        /// <param name="mappingProvider">A <see cref="IMarketMappingProvider"/> instance used for providing mapped ids of markets and outcomes</param>
        /// <param name="marketDefinition">The associated market definition</param>
        /// <param name="voidReason">A value specifying the void reason or a null reference</param>
        /// <param name="voidReasonsCache">A <see cref="INamedValueCache"/> used to get void reason descriptions</param>
        /// <param name="cultures">A <see cref="IEnumerable{CultureInfo}"/> specifying languages the current instance supports</param>
        internal MarketWithSettlement(int id,
                                      IReadOnlyDictionary <string, string> specifiers,
                                      IReadOnlyDictionary <string, string> additionalInfo,
                                      IEnumerable <IOutcomeSettlement> outcomes,
                                      INameProvider nameProvider,
                                      IMarketMappingProvider mappingProvider,
                                      IMarketDefinition marketDefinition,
                                      int?voidReason,
                                      INamedValueCache voidReasonsCache,
                                      IEnumerable <CultureInfo> cultures)
            : base(id, specifiers, additionalInfo, nameProvider, mappingProvider, marketDefinition, voidReason, voidReasonsCache, cultures)
        {
            Contract.Requires(outcomes != null && outcomes.Any());

            var readonlyOutcomes = outcomes as IReadOnlyCollection <IOutcomeSettlement>;

            OutcomeSettlements = readonlyOutcomes ?? new ReadOnlyCollection <IOutcomeSettlement>(outcomes.ToList());
        }
Esempio n. 14
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Market" /> class
 /// </summary>
 /// <param name="id">a <see cref="int" /> value specifying the market type</param>
 /// <param name="specifiers">a <see cref="IReadOnlyDictionary{String, String}" /> containing market specifiers</param>
 /// <param name="additionalInfo">a <see cref="IReadOnlyDictionary{String, String}" /> containing additional market info</param>
 /// <param name="nameProvider">A <see cref="INameProvider"/> instance used to generate the market name(s) </param>
 /// <param name="mappingProvider">A <see cref="IMarketMappingProvider"/> instance used for providing mapping ids of markets and outcomes</param>
 /// <param name="marketDefinition">The associated market definition</param>
 /// <param name="cultures">A <see cref="IEnumerable{CultureInfo}"/> specifying languages the current instance supports</param>
 internal Market(int id,
                 IReadOnlyDictionary <string, string> specifiers,
                 IReadOnlyDictionary <string, string> additionalInfo,
                 INameProvider nameProvider,
                 IMarketMappingProvider mappingProvider,
                 IMarketDefinition marketDefinition,
                 IEnumerable <CultureInfo> cultures)
 {
     Guard.Argument(nameProvider, nameof(nameProvider)).NotNull();
     Guard.Argument(cultures, nameof(cultures)).NotNull().NotEmpty();
     Id               = id;
     Specifiers       = specifiers;
     AdditionalInfo   = additionalInfo;
     _nameProvider    = nameProvider;
     MappingProvider  = mappingProvider;
     MarketDefinition = marketDefinition;
     _cultures        = cultures;
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="PlayerOutcomeOdds" /> class
        /// </summary>
        /// <param name="id">the value uniquely identifying the current <see cref="PlayerOutcomeOdds" /> instance</param>
        /// <param name="active">
        /// a value indicating whether the current <see cref="OutcomeOdds" /> is active - i.e. should bets on
        /// it be accepted
        /// </param>
        /// <param name="odds">the odds for the current <see cref="OutcomeOdds" /> instance</param>
        /// <param name="probabilities">the probabilities for the current <see cref="OutcomeOdds" /> instance</param>
        /// <param name="nameProvider">A <see cref="INameProvider"/> used to generate the outcome name(s)</param>
        /// <param name="mappingProvider">A <see cref="IMarketMappingProvider"/> instance used for providing mapping ids of markets and outcomes</param>
        /// <param name="match">A <see cref="IMatch"/> representing the match associated with the outcome / market</param>
        /// <param name="teamFlag">A value indicating whether the player is associated with home or away team - 1 : HomeTeam, 2 : AwayTeam</param>
        /// <param name="cultures">A <see cref="IEnumerable{CultureInfo}"/> specifying languages the current instance supports</param>
        /// <param name="outcomeDefinition">The associated <see cref="IOutcomeDefinition"/></param>
        /// <param name="additionalProbabilities">Additional probability attributes for markets which potentially will be (partly) refunded</param>
        internal PlayerOutcomeOdds(string id,
                                   bool?active,
                                   double odds,
                                   double?probabilities,
                                   INameProvider nameProvider,
                                   IMarketMappingProvider mappingProvider,
                                   IMatch match,
                                   int teamFlag,
                                   IEnumerable <CultureInfo> cultures,
                                   IOutcomeDefinition outcomeDefinition,
                                   IAdditionalProbabilities additionalProbabilities)
            : base(id, active, odds, probabilities, nameProvider, mappingProvider, cultures, outcomeDefinition, additionalProbabilities)
        {
            Guard.Argument(match, nameof(match)).NotNull();
            Guard.Argument(teamFlag, nameof(teamFlag)).InRange(1, 2);

            _teamFlag = teamFlag;
            _match    = match;
        }
Esempio n. 16
0
        /// <summary>
        ///     Initializes a new instance of the <see cref="Market" /> class
        /// </summary>
        /// <param name="id">a <see cref="int" /> value specifying the market type</param>
        /// <param name="specifiers">a <see cref="IReadOnlyDictionary{String, String}" /> containing market specifiers</param>
        /// <param name="additionalInfo">a <see cref="IReadOnlyDictionary{String, String}" /> containing additional market info</param>
        /// <param name="nameProvider">A <see cref="INameProvider"/> instance used to generate the market name(s) </param>
        /// <param name="mappingProvider">A <see cref="IMarketMappingProvider"/> instance used for providing mapping ids of markets and outcomes</param>
        /// <param name="marketDefinition">The associated market definition</param>
        /// <param name="cultures">A <see cref="IEnumerable{CultureInfo}"/> specifying languages the current instance supports</param>
        internal Market(int id,
                        IReadOnlyDictionary <string, string> specifiers,
                        IReadOnlyDictionary <string, string> additionalInfo,
                        INameProvider nameProvider,
                        IMarketMappingProvider mappingProvider,
                        IMarketDefinition marketDefinition,
                        IEnumerable <CultureInfo> cultures)
        {
            Contract.Requires(nameProvider != null);
            Contract.Requires(cultures != null);
            Contract.Requires(cultures.Any());

            Id               = id;
            Specifiers       = specifiers;
            AdditionalInfo   = additionalInfo;
            _nameProvider    = nameProvider;
            MappingProvider  = mappingProvider;
            MarketDefinition = marketDefinition;
            _cultures        = cultures;
        }
Esempio n. 17
0
 /// <summary>Initializes a new instance of the <see cref="OutcomeSettlement" /> class</summary>
 /// <param name="deadHeatFactor">a dead-head factor for the current <see cref="IOutcomeSettlement" /> instance.</param>
 /// <param name="id">the value uniquely identifying the current <see cref="IOutcomeSettlement" /></param>
 /// <param name="result">a value indicating whether the outcome associated with current <see cref="IOutcomeSettlement" /> is winning</param>
 /// <param name="voidFactor">the <see cref="VoidFactor" /> associated with a current <see cref="IOutcomeSettlement" /> or a null reference</param>
 /// <param name="nameProvider">A <see cref="INameProvider"/> used to generate the outcome name(s)</param>
 /// <param name="mappingProvider">A <see cref="IMarketMappingProvider"/> instance used for providing mapping ids of markets and outcomes</param>
 /// <param name="cultures">A <see cref="IEnumerable{CultureInfo}"/> specifying languages the current instance supports</param>
 /// <param name="outcomeDefinition">The associated <see cref="IOutcomeDefinition"/></param>
 internal OutcomeSettlement(double?deadHeatFactor,
                            string id,
                            int result,
                            VoidFactor?voidFactor,
                            INameProvider nameProvider,
                            IMarketMappingProvider mappingProvider,
                            IEnumerable <CultureInfo> cultures,
                            IOutcomeDefinition outcomeDefinition)
     : base(id, nameProvider, mappingProvider, cultures, outcomeDefinition)
 {
     DeadHeatFactor = deadHeatFactor;
     Result         = result == 1;
     VoidFactor     = voidFactor;
     OutcomeResult  = result switch
     {
         0 => OutcomeResult.Lost,
         1 => OutcomeResult.Won,
         _ => OutcomeResult.UndecidedYet
     };
 }
        /// <summary>
        /// Gets the new <see cref="IOutcomeOdds"/> instances
        /// </summary>
        /// <param name="sportEvent">The <see cref="ISportEvent"/> associated with the market</param>
        /// <param name="nameProvider">The <see cref="INameProvider"/> used to generate outcome name</param>
        /// <param name="mappingProvider">The <see cref="IMarketMappingProvider"/> used to provide market mapping</param>
        /// <param name="outcome">The <see cref="oddsChangeMarketOutcome"/> representing the outcome to be mapped</param>
        /// <param name="cultures">A <see cref="IEnumerable{CultureInfo}"/> specifying languages the current instance supports</param>
        /// <param name="outcomeDefinition">The associated <see cref="IOutcomeDefinition"/></param>
        /// <returns>IOutcomeOdds</returns>
        protected virtual IOutcomeOdds GetOutcomeWithOdds(ISportEvent sportEvent,
                                                          INameProvider nameProvider,
                                                          IMarketMappingProvider mappingProvider,
                                                          oddsChangeMarketOutcome outcome,
                                                          IEnumerable <CultureInfo> cultures,
                                                          IOutcomeDefinition outcomeDefinition)
        {
            var    isValidPlayerOutcome = false;
            IMatch match = null;

            if (outcome.teamSpecified)
            {
                match = sportEvent as IMatch;
                isValidPlayerOutcome = !(match == null || outcome.team < 1 || outcome.team > 2);
            }

            if (isValidPlayerOutcome)
            {
                return(new PlayerOutcomeOdds(outcome.id,
                                             outcome.activeSpecified ? (bool?)(outcome.active != 0) : null,
                                             outcome.odds,
                                             outcome.probabilitiesSpecified ? (double?)outcome.probabilities : null,
                                             nameProvider,
                                             mappingProvider,
                                             match,
                                             outcome.team,
                                             cultures,
                                             outcomeDefinition,
                                             GetAdditionalProbabilities(outcome)));
            }

            return(new OutcomeOdds(outcome.id,
                                   outcome.activeSpecified ? (bool?)(outcome.active != 0) : null,
                                   outcome.odds,
                                   outcome.probabilitiesSpecified ? (double?)outcome.probabilities : null,
                                   nameProvider,
                                   mappingProvider,
                                   cultures,
                                   outcomeDefinition,
                                   GetAdditionalProbabilities(outcome)));
        }