Ejemplo n.º 1
0
        private async Task <IEnumerable <TennisPrediction> > FetchGenericTennisPredictions(DateTime matchDate)
        {
            var sport      = this.fixtureRepository.GetSport("Tennis");
            var tournament = this.fixtureRepository.GetTournament("ATP");
            var couponDate = matchDate.Date;
            var source     = this.fixtureRepository.GetExternalSource("Tennis Betting 365");

            var valueOptions = new ValueOptions
            {
                Tournament = tournament,
                Sport      = sport,
                CouponDate = matchDate,
                OddsSource = source
            };

            var predictionStrategy =
                this.predictionProvider
                .CreatePredictionStrategy(sport);

            var predictions = await
                              predictionStrategy.FetchPredictionsAsync(valueOptions);

            var tennisPredictions =
                predictions.Cast <TennisPrediction>()
                .ToList();

            return(tennisPredictions);
        }
Ejemplo n.º 2
0
        public ConditionViewModel(IEnumerable <MappingViewModel> mappings, ConditionNumber number, ACondition condition)
        {
            _mappings  = mappings;
            _number    = number;
            _condition = condition;

            if (_condition != null)
            {
                _name = _condition.Name;

                // assignment
                var options = _condition.AssignmentOptions.Select(a => new ConditionAssignment {
                    Target = a.Key, Description = a.Value
                });
                _assignmentOptions = new ObservableCollection <ConditionAssignment>(options);
                _assignment        = AssignmentOptions.SingleOrDefault(a => a.Target == _condition.Assignment);

                // value
                var enumDict = _condition.GetValueOptions();
                _valueOptions = new ObservableCollection <ConditionValue>(enumDict.Select(e => new ConditionValue {
                    Value = e.Key, Description = e.Value
                }));
                _value = ValueOptions.SingleOrDefault(v => v.Value != null && v.Value.Equals(_condition.GetValue()));
            }
        }
Ejemplo n.º 3
0
        public async Task <TennisFixtureViewModel> GetSingleTennisPrediction(string playerASurname, string playerAFirstname, string playerBSurname, string playerBFirstname, int year, string tournamentSlug, bool updateStats = true)
        {
            var sport        = this.fixtureRepository.GetSport("Tennis");
            var tournament   = this.fixtureRepository.GetTournamentFromSlug(tournamentSlug);
            var playerA      = this.fixtureRepository.GetTeamOrPlayerFromNameAndMaybeFirstName(playerASurname, playerAFirstname);
            var playerB      = this.fixtureRepository.GetTeamOrPlayerFromNameAndMaybeFirstName(playerBSurname, playerBFirstname);
            var safeDate     = new DateTime(year, 06, 29);
            var valueOptions = new ValueOptions
            {
                CouponDate            = safeDate,
                Tournament            = tournament,
                DontUpdateTennisStats = !updateStats
            };

            var provider   = this.predictionProvider.CreatePredictionStrategy(sport);
            var prediction =
                (TennisPrediction)await provider.FetchSinglePredictionAsync(playerA, playerB, tournament, valueOptions);

            var tennisPredictionStat = new TennisPredictionStat
            {
                PlayerAGames = prediction.PlayerAGames,
                PlayerBGames = prediction.PlayerBGames,
                EPoints      = (decimal?)prediction.EPoints,
                EGames       = (decimal?)prediction.EGames,
                ESets        = (decimal?)prediction.ESets
            };
            var tennisMatchDetail = new TennisMatchDetail()
            {
                TennisPredictionStat = tennisPredictionStat,
                TennisPrediction     = prediction
            };

            return(Mapper.Map <TennisMatchDetail, TennisFixtureViewModel>(tennisMatchDetail)); //no idea what HydrateFullTennisMatchDetails was for in the first place, I only need predictions and number of games for now
        }
Ejemplo n.º 4
0
 internal Setting(
     Id id,
     ValueOptions flags,
     uint value)
 {
     Id    = id;
     Flags = flags;
     Value = value;
 }
Ejemplo n.º 5
0
        public CacheEntry([DisallowNull] T value, ValueOptions options)
        {
            Options   = options;
            _refCount = 1;

            if (IsWeakReference)
            {
                _weakReference = new WeakReference(value);
            }
            else
            {
                _value = value;
            }
        }
Ejemplo n.º 6
0
        public async ValueTask SetValue(TKey key, [DisallowNull] TValue value, ValueOptions options)
        {
            if (_localDictionary.TryGetValue(key, out var entry))
            {
                await DropEntry(key, entry).ConfigureAwait(false);
            }

            var newEntry = new CacheEntry <TValue>(value, options);

            _localDictionary[key] = newEntry;

            if ((options & ValueOptions.ThreadSafe) != 0)
            {
                _globalDictionary[key] = newEntry;
            }
        }
Ejemplo n.º 7
0
        private readonly TValue[] m_cache = new TValue[4];   // one for each possible ValueOption


        internal static ValueOptions ComputeValueOptions(bool skipConversion,
                                                         bool skipDerivedTypeDetection)
        {
            ValueOptions valOpts = ValueOptions.Raw;

            if (!skipConversion)
            {
                valOpts |= ValueOptions.DoSymbolValueConversion;
            }

            if (!skipDerivedTypeDetection)
            {
                valOpts |= ValueOptions.DoDerivedTypeDetection;
            }

            return(valOpts);
        } // end _ComputeValueOptions()
Ejemplo n.º 8
0
        } // end _ComputeValueOptions()

        public TValue this[bool skipConversion, bool skipDerivedTypeDetection]
        {
            get
            {
                ValueOptions valOpts = ComputeValueOptions(skipConversion,
                                                           skipDerivedTypeDetection);

                return(m_cache[(int)valOpts]);
            }

            set
            {
                ValueOptions valOpts = ComputeValueOptions(skipConversion,
                                                           skipDerivedTypeDetection);

                m_cache[(int)valOpts] = value;
            }
        } // end indexer
Ejemplo n.º 9
0
        public PSObject GetValue(bool skipConversion, bool skipDerivedTypeDetection)
        {
            ValueOptions valOpts = DbgValueCache <PSObject> .ComputeValueOptions(skipConversion,
                                                                                 skipDerivedTypeDetection);

            ref PSObject val = ref m_valueCache[valOpts];
Ejemplo n.º 10
0
        } // end indexer


        /// <summary>
        ///    Internal ref-getter (which allows the caller to set the value).
        /// </summary>
        internal ref TValue this[ValueOptions valOpts]
        {
            get
            {
                return(ref m_cache[(int)valOpts]);