/// <summary> /// Asynchronously gets a <see cref="ISportSummary" /> representing the sport to which the tournament belongs to /// </summary> /// <returns>A <see cref="Task{ISportSummary}" /> representing the asynchronous operation</returns> public async Task <ISportSummary> GetSportAsync() { var tournamentInfoCI = (TournamentInfoCI)SportEventCache.GetEventCacheItem(Id); if (tournamentInfoCI == null) { ExecutionLogPrivate.Debug($"Missing data. No tournament cache item for id={Id}."); return(null); } var sportId = ExceptionStrategy == ExceptionHandlingStrategy.THROW ? await tournamentInfoCI.GetSportIdAsync().ConfigureAwait(false) : await new Func <Task <URN> >(tournamentInfoCI.GetSportIdAsync) .SafeInvokeAsync(ExecutionLog, GetFetchErrorMessage("SportId")).ConfigureAwait(false); if (sportId == null) { ExecutionLogPrivate.Debug($"Missing data. No sportId for tournament cache item with id={Id}."); return(null); } var sportData = ExceptionStrategy == ExceptionHandlingStrategy.THROW ? await _sportDataCache.GetSportAsync(sportId, Cultures).ConfigureAwait(false) : await new Func <URN, IEnumerable <CultureInfo>, Task <SportData> >(_sportDataCache.GetSportAsync) .SafeInvokeAsync(sportId, Cultures, ExecutionLog, GetFetchErrorMessage("SportData")) .ConfigureAwait(false); return(sportData == null ? null : new SportSummary(sportData.Id, sportData.Names)); }
/// <summary> /// get competitors as an asynchronous operation. /// </summary> /// <returns>Task<IEnumerable<ICompetitor>></returns> /// <value>The competitors</value> public async Task <IEnumerable <ICompetitor> > GetCompetitorsAsync() { var tournamentInfoCI = (TournamentInfoCI)SportEventCache.GetEventCacheItem(Id); if (tournamentInfoCI == null) { ExecutionLogPrivate.Debug($"Missing data. No tournament cache item for id={Id}."); return(null); } var items = ExceptionStrategy == ExceptionHandlingStrategy.THROW ? await tournamentInfoCI.GetCompetitorsIdsAsync(Cultures).ConfigureAwait(false) : await new Func <IEnumerable <CultureInfo>, Task <IEnumerable <URN> > >(tournamentInfoCI.GetCompetitorsIdsAsync).SafeInvokeAsync(Cultures, ExecutionLog, GetFetchErrorMessage("CompetitorsIds")).ConfigureAwait(false); var competitorsIds = items == null ? new List <URN>() : items.ToList(); if (!competitorsIds.Any()) { return(new List <ICompetitor>()); } var competitorsReferences = await tournamentInfoCI.GetCompetitorsReferencesAsync().ConfigureAwait(false); var tasks = competitorsIds.Select(s => _sportEntityFactory.BuildCompetitorAsync(s, Cultures, competitorsReferences, ExceptionStrategy)).ToList(); await Task.WhenAll(tasks).ConfigureAwait(false); return(tasks.Select(s => s.Result)); }
/// <summary> /// Asynchronously gets the associated category /// </summary> /// <returns>The associated category</returns> public async Task <ICategorySummary> GetCategoryAsync() { var lotteryCI = (LotteryCI)SportEventCache.GetEventCacheItem(Id); if (lotteryCI == null) { ExecutionLog.LogDebug($"Missing data. No lottery cache item for id={Id}."); return(null); } var categoryId = ExceptionStrategy == ExceptionHandlingStrategy.THROW ? await lotteryCI.GetCategoryIdAsync().ConfigureAwait(false) : await new Func <Task <URN> >(lotteryCI.GetCategoryIdAsync).SafeInvokeAsync(ExecutionLog, GetFetchErrorMessage("CategoryId")).ConfigureAwait(false); if (categoryId == null) { ExecutionLog.LogDebug($"Missing data. No categoryId for lottery cache item with id={Id}."); return(null); } var categoryData = ExceptionStrategy == ExceptionHandlingStrategy.THROW ? await _sportDataCache.GetCategoryAsync(categoryId, Cultures).ConfigureAwait(false) : await new Func <URN, IEnumerable <CultureInfo>, Task <CategoryData> >(_sportDataCache.GetCategoryAsync).SafeInvokeAsync(categoryId, Cultures, ExecutionLog, GetFetchErrorMessage("CategoryData")).ConfigureAwait(false); return(categoryData == null ? null : new CategorySummary(categoryData.Id, categoryData.Names, categoryData.CountryCode)); }
/// <summary> /// Get current season as an asynchronous operation /// </summary> /// <returns>A <see cref="Task{ICurrentSeasonInfo}" /> representing the asynchronous operation</returns> public async Task <ICurrentSeasonInfo> GetCurrentSeasonAsync() { var tournamentInfoCI = (TournamentInfoCI)SportEventCache.GetEventCacheItem(Id); if (tournamentInfoCI == null) { ExecutionLogPrivate.Debug($"Missing data. No tournament cache item for id={Id}."); return(null); } var currentSeasonInfoCI = ExceptionStrategy == ExceptionHandlingStrategy.THROW ? await tournamentInfoCI.GetCurrentSeasonInfoAsync(Cultures).ConfigureAwait(false) : await new Func <IEnumerable <CultureInfo>, Task <CurrentSeasonInfoCI> >(tournamentInfoCI .GetCurrentSeasonInfoAsync) .SafeInvokeAsync(Cultures, ExecutionLog, GetFetchErrorMessage("CurrentSeasonInfo")) .ConfigureAwait(false); if (currentSeasonInfoCI == null) { return(null); } var competitorsReferences = await tournamentInfoCI.GetCompetitorsReferencesAsync().ConfigureAwait(false); //we do have current season, but need to load the correct one var currentSeasonTournamentInfoCI = (TournamentInfoCI)SportEventCache.GetEventCacheItem(currentSeasonInfoCI.Id); var seasonTournamentInfoCurrentSeasonInfo = currentSeasonTournamentInfoCI == null ? new CurrentSeasonInfo(currentSeasonInfoCI, Cultures, _sportEntityFactory, ExceptionStrategy, competitorsReferences) : new CurrentSeasonInfo(currentSeasonTournamentInfoCI, Cultures, _sportEntityFactory, ExceptionStrategy, competitorsReferences); return(seasonTournamentInfoCurrentSeasonInfo); }
public void Init() { _timer = new TestTimer(false); _eventMemoryCache = new MemoryCache("EventCache"); _profileCache = new MemoryCache("ProfileCache"); _statusMemoryCache = new MemoryCache("StatusCache"); _cacheManager = new CacheManager(); _dataRouterManager = new TestDataRouterManager(_cacheManager); var sportEventCacheItemFactory = new SportEventCacheItemFactory(_dataRouterManager, new SemaphorePool(5), TestData.Culture, new MemoryCache("FixtureTimestampCache")); var profileCache = new ProfileCache(_profileCache, _dataRouterManager, _cacheManager); SportEventCache = new SportEventCache(_eventMemoryCache, _dataRouterManager, sportEventCacheItemFactory, _timer, TestData.Cultures3, _cacheManager); SportDataCache = new SportDataCache(_dataRouterManager, _timer, TestData.Cultures3, SportEventCache, _cacheManager); var sportEventStatusCache = new TestLocalizedNamedValueCache(); var namedValuesProviderMock = new Mock <INamedValuesProvider>(); namedValuesProviderMock.Setup(args => args.MatchStatuses).Returns(sportEventStatusCache); EventStatusCache = new SportEventStatusCache(_statusMemoryCache, new SportEventStatusMapperFactory(), SportEventCache, _cacheManager, TimeSpan.Zero); SportEntityFactory = new SportEntityFactory(SportDataCache, SportEventCache, EventStatusCache, sportEventStatusCache, profileCache, SdkInfo.SoccerSportUrns); }
/// <summary> /// Asynchronously gets a <see cref="ITeamCompetitor" /> representing away competitor of the match associated with the current instance /// </summary> /// <returns>A <see cref="Task{ITeamCompetitor}"/> representing the retrieval operation</returns> public async Task<ITeamCompetitor> GetAwayCompetitorAsync() { var matchCI = (IMatchCI)SportEventCache.GetEventCacheItem(Id); if (matchCI == null) { ExecutionLog.Debug($"Missing data. No match cache item for id={Id}."); return null; } var items = ExceptionStrategy == ExceptionHandlingStrategy.THROW ? await matchCI.GetCompetitorsIdsAsync(Cultures).ConfigureAwait(false) : await new Func<IEnumerable<CultureInfo>, Task<IEnumerable<URN>>>(matchCI.GetCompetitorsIdsAsync).SafeInvokeAsync(Cultures, ExecutionLog, GetFetchErrorMessage("CompetitorsIds")).ConfigureAwait(false); if (items == null) { return null; } var competitorUrns = items.ToList(); if (competitorUrns.Count == 2) { return await _sportEntityFactory.BuildTeamCompetitorAsync(competitorUrns[1], Cultures, matchCI, ExceptionStrategy).ConfigureAwait(false); } ExecutionLog.Error($"Received {competitorUrns.Count} competitors for match[Id = {Id}]. Match can have only 2 competitors."); throw new InvalidOperationException($"Invalid number of competitors. Match must have exactly 2 competitors, received {competitorUrns.Count}"); }
public async Task <IStage> GetParentStageAsync() { var stageCI = (StageCI)SportEventCache.GetEventCacheItem(Id); if (stageCI == null) { ExecutionLog.LogDebug($"Missing data. No stage cache item for id={Id}."); return(null); } var parentStageId = await stageCI.GetParentStageAsync(Cultures).ConfigureAwait(false); if (parentStageId != null) { //var parentStageCI = (StageCI) SportEventCache.GetEventCacheItem(parentStageId); //if (parentStageCI == null) //{ // return new Stage(parentStageId, GetSportAsync().Result.Id, _sportEntityFactory, SportEventCache, _sportDataCache, SportEventStatusCache, _matchStatusesCache, Cultures, ExceptionStrategy); //} return(new Stage(parentStageId, GetSportAsync().Result.Id, _sportEntityFactory, SportEventCache, _sportDataCache, SportEventStatusCache, MatchStatusCache, Cultures, ExceptionStrategy)); } return(null); }
public void Init() { _memoryCache = new MemoryCache("sportEventCache"); _cacheManager = new CacheManager(); _dataRouterManager = new TestDataRouterManager(_cacheManager); _timer = new TestTimer(false); _sportEventCache = new SportEventCache(_memoryCache, _dataRouterManager, new SportEventCacheItemFactory(_dataRouterManager, new SemaphorePool(5, ExceptionHandlingStrategy.THROW), TestData.Cultures.First(), new MemoryCache("FixtureTimestampCache")), _timer, TestData.Cultures3, _cacheManager); var deserializer = new Deserializer <tournamentInfoEndpoint>(); var dataFetcher = new TestDataFetcher(); var mapperFactory = new TournamentInfoMapperFactory(); var tourDataProvider = new DataProvider <tournamentInfoEndpoint, TournamentInfoDTO>(TestData.RestXmlPath + TourInfoXml, dataFetcher, deserializer, mapperFactory); _tourApiData = deserializer.Deserialize(dataFetcher.GetData(new Uri(string.Format(TestData.RestXmlPath + TourInfoXml)))); _tourDtoData = tourDataProvider.GetDataAsync("", "en").Result; _tourCiData = (TournamentInfoCI)_sportEventCache.GetEventCacheItem(URN.Parse("sr:tournament:40")); var seasonDataProvider = new DataProvider <tournamentInfoEndpoint, TournamentInfoDTO>(TestData.RestXmlPath + SeasonInfoXml, dataFetcher, deserializer, mapperFactory); _seasonApiData = deserializer.Deserialize(dataFetcher.GetData(new Uri(string.Format(TestData.RestXmlPath + SeasonInfoXml)))); _seasonDtoData = seasonDataProvider.GetDataAsync("", "en").Result; _seasonCiData = (TournamentInfoCI)_sportEventCache.GetEventCacheItem(URN.Parse("sr:season:80242")); }
/// <summary> /// Asynchronously gets a <see cref="IEnumerable{T}"/> representing competitors in the sport event associated with the current instance /// </summary> /// <returns>A <see cref="Task{T}"/> representing the retrieval operation</returns> public async Task <IEnumerable <ICompetitor> > GetCompetitorsAsync() { var competitionCI = (CompetitionCI)SportEventCache.GetEventCacheItem(Id); if (competitionCI == null) { ExecutionLog.LogDebug($"Missing data. No sportEvent cache item for id={Id}."); return(null); } var items = ExceptionStrategy == ExceptionHandlingStrategy.THROW ? await competitionCI.GetCompetitorsAsync(Cultures).ConfigureAwait(false) : await new Func <IEnumerable <CultureInfo>, Task <IEnumerable <URN> > >(competitionCI.GetCompetitorsAsync).SafeInvokeAsync(Cultures, ExecutionLog, GetFetchErrorMessage("Competitors")).ConfigureAwait(false); var competitorUrns = items as List <URN>; if (competitorUrns == null || !competitorUrns.Any()) { return(null); } var tasks = competitorUrns.Select(s => { var t = _sportEntityFactory.BuildTeamCompetitorAsync(s, Cultures, competitionCI); t.ConfigureAwait(false); return(t); }).ToList(); await Task.WhenAll(tasks).ConfigureAwait(false); return(tasks.Select(s => s.Result)); }
public void Init() { _memoryCache = new MemoryCache("sportEventCache"); _cacheManager = new CacheManager(); _dataRouterManager = new TestDataRouterManager(_cacheManager); _timer = new TestTimer(false); _sportEventCache = new SportEventCache(_memoryCache, _dataRouterManager, new SportEventCacheItemFactory(_dataRouterManager, new SemaphorePool(5), TestData.Cultures.First(), new MemoryCache("FixtureTimestampCache")), _timer, TestData.Cultures, _cacheManager); }
public async Task <StageType> GetStageTypeAsync() { var stageCI = (StageCI)SportEventCache.GetEventCacheItem(Id); if (stageCI == null) { ExecutionLog.Debug($"Missing data. No stage cache item for id={Id}."); return(StageType.Child); } return(await stageCI.GetTypeAsync().ConfigureAwait(false)); }
public void Init() { _cacheManager = new CacheManager(); _dataRouterManager = new TestDataRouterManager(_cacheManager); _timer = new TestTimer(false); _sportEventCache = new SportEventCache(new MemoryCache("tournamentDetailsCache"), _dataRouterManager, new SportEventCacheItemFactory(_dataRouterManager, new SemaphorePool(5), TestData.Cultures.First(), new MemoryCache("FixtureTimestampCache")), _timer, TestData.Cultures, _cacheManager); _sportDataCache = new SportDataCache(_dataRouterManager, _timer, TestData.Cultures, _sportEventCache, _cacheManager); _profileMemoryCache = new MemoryCache("profileCache"); _profileCache = new ProfileCache(_profileMemoryCache, _dataRouterManager, _cacheManager); }
public void Init() { _memoryCache = new MemoryCache("tournamentDetailsCache"); _cacheManager = new CacheManager(); _dataRouterManager = new TestDataRouterManager(_cacheManager); _timer = new TestTimer(false); _sportEventCache = new SportEventCache(_memoryCache, _dataRouterManager, new SportEventCacheItemFactory(_dataRouterManager, new SemaphorePool(5, ExceptionHandlingStrategy.THROW), TestData.Cultures.First(), new MemoryCache("FixtureTimestampCache")), _timer, TestData.Cultures, _cacheManager); _sportDataCache = new SportDataCache(_dataRouterManager, _timer, TestData.Cultures, _sportEventCache, _cacheManager); }
/// <summary> /// Asynchronously gets a <see cref="IFixture"/> instance containing information about the arranged sport event /// </summary> /// <returns>A <see cref="Task{IFixture}"/> representing the retrieval operation</returns> /// <remarks>A Fixture is a sport event that has been arranged for a particular time and place</remarks> public async Task<IFixture> GetFixtureAsync() { var matchCI = (IMatchCI)SportEventCache.GetEventCacheItem(Id); if (matchCI == null) { ExecutionLog.Debug($"Missing data. No match cache item for id={Id}."); return null; } return ExceptionStrategy == ExceptionHandlingStrategy.THROW ? await matchCI.GetFixtureAsync(Cultures).ConfigureAwait(false) : await new Func<IEnumerable<CultureInfo>, Task<IFixture>>(matchCI.GetFixtureAsync).SafeInvokeAsync(Cultures, ExecutionLog, GetFetchErrorMessage("Fixture")).ConfigureAwait(false); }
/// <summary> /// Asynchronously gets a <see cref="BookingStatus"/> enum member providing booking status for the associated @event or a null reference if booking status is not known /// </summary> /// <returns></returns> public async Task<BookingStatus?> GetBookingStatusAsync() { var competitionCI = (CompetitionCI)SportEventCache.GetEventCacheItem(Id); if (competitionCI == null) { ExecutionLog.Debug($"Missing data. No sportEvent cache item for id={Id}."); return null; } return ExceptionStrategy == ExceptionHandlingStrategy.THROW ? await competitionCI.GetBookingStatusAsync().ConfigureAwait(false) : await new Func<Task<BookingStatus?>>(competitionCI.GetBookingStatusAsync).SafeInvokeAsync(ExecutionLog, GetFetchErrorMessage("BookingStatus")).ConfigureAwait(false); }
/// <summary> /// Asynchronously gets a <see cref="ITournamentInfo" /> representing the tournament info /// </summary> /// <returns>A <see cref="Task{ITournamentInfo}" /> representing the asynchronous operation</returns> public async Task <ITournamentInfo> GetTournamentInfoAsync() { var seasonCI = (ITournamentInfoCI)_sportEventCache.GetEventCacheItem(Id); if (seasonCI == null) { ExecutionLogPrivate.Debug($"Missing data. No tournament cache item for id={Id}."); return(null); } var tournamentInfoBasicCI = ExceptionStrategy == ExceptionHandlingStrategy.THROW ? await seasonCI.GetTournamentInfoAsync().ConfigureAwait(false) : await new Func <Task <TournamentInfoBasicCI> >(seasonCI.GetTournamentInfoAsync) .SafeInvokeAsync(ExecutionLog, GetFetchErrorMessage("TournamentInfoBasic")).ConfigureAwait(false); if (tournamentInfoBasicCI == null) { ExecutionLogPrivate.Debug($"Missing data. No tournament info basic for cache item with id={Id}."); return(null); } var categoryId = await seasonCI.GetCategoryIdAsync().ConfigureAwait(false); if (categoryId == null) { return(null); } var categoryCI = await _sportDataCache.GetCategoryAsync(categoryId, Cultures).ConfigureAwait(false); var categorySummary = categoryCI == null ? null : new CategorySummary(categoryCI.Id, categoryCI.Names, categoryCI.CountryCode); var currentSeasonCI = tournamentInfoBasicCI.CurrentSeason == null ? null : Id.Equals(tournamentInfoBasicCI.CurrentSeason.Id) ? seasonCI : (TournamentInfoCI)SportEventCache.GetEventCacheItem(tournamentInfoBasicCI.CurrentSeason.Id); // there is no current season - return empty TournamentInfo if (currentSeasonCI == null) { return(new TournamentInfo(tournamentInfoBasicCI, categorySummary, null)); } var competitorsReferences = await seasonCI.GetCompetitorsReferencesAsync().ConfigureAwait(false); //we do have current season, but need to load the correct one var seasonTournamentInfoCurrentSeasonInfo = new CurrentSeasonInfo(currentSeasonCI, Cultures, _sportEntityFactory, ExceptionStrategy, competitorsReferences); return(new TournamentInfo(tournamentInfoBasicCI, categorySummary, seasonTournamentInfoCurrentSeasonInfo)); }
private void InitSportEventCache() { var testDataFetcher = new TestDataFetcher(); _eventCache = new MemoryCache("test"); var fixtureDeserializer = new Deserializer <fixturesEndpoint>(); var fixtureMapperFactory = new FixtureMapperFactory(); var fixtureProvider = new DataProvider <fixturesEndpoint, FixtureDTO>( DirPath + FixtureXml, testDataFetcher, fixtureDeserializer, fixtureMapperFactory); var dateDeserializer = new Deserializer <scheduleEndpoint>(); var dateMapperFactory = new SportEventsScheduleMapperFactory(); var dateProvider = new DateScheduleProvider( DirPath + ScheduleXml, DirPath + ScheduleXml, testDataFetcher, dateDeserializer, dateMapperFactory); // tournament schedule provider var tourDeserializer = new Deserializer <tournamentScheduleEndpoint>(); var tourMapperFactory = new TournamentScheduleMapperFactory(); var tourProvider = new DataProvider <tournamentScheduleEndpoint, EntityList <MatchSummaryDTO> >( DirPath + TourXml, testDataFetcher, tourDeserializer, tourMapperFactory); var detailsDeserializer = new Deserializer <matchSummaryEndpoint>(); var detailsMapperFactory = new SportEventDetailsMapperFactory(); var eventDetailsProvider = new DataProvider <matchSummaryEndpoint, SportEventDetailsDTO>( DirPath + DetailsXml, testDataFetcher, detailsDeserializer, detailsMapperFactory); var timer = new TestTimer(false); _sportEventCacheItemFactory = new SportEventCacheItemFactory(fixtureProvider, eventDetailsProvider, DefaultCulture); _sportEventCache = new SportEventCache(_eventCache, dateProvider, tourProvider, _sportEventCacheItemFactory, timer, Cultures); }
/// <summary> /// Gets the list of all <see cref="ICompetition"/> that belongs to the basic tournament schedule /// </summary> /// <returns>The list of all <see cref="ICompetition"/> that belongs to the basic tournament schedule</returns> public async Task <IEnumerable <ISportEvent> > GetScheduleAsync() { var tournamentInfoCI = (TournamentInfoCI)SportEventCache.GetEventCacheItem(Id); if (tournamentInfoCI == null) { ExecutionLogPrivate.Debug($"Missing data. No tournament cache item for id={Id}."); return(null); } var item = ExceptionStrategy == ExceptionHandlingStrategy.THROW ? await tournamentInfoCI.GetScheduleAsync(Cultures).ConfigureAwait(false) : await new Func <IEnumerable <CultureInfo>, Task <IEnumerable <URN> > >(tournamentInfoCI.GetScheduleAsync).SafeInvokeAsync(Cultures, ExecutionLog, GetFetchErrorMessage("Schedule")).ConfigureAwait(false); return(item?.Select(s => _sportEntityFactory.BuildSportEvent <ISportEvent>(s, SportId, Cultures, ExceptionStrategy))); }
/// <summary> /// Asynchronously gets a <see cref="IRound"/> representing the tournament round to which the sport event associated with the current instance belongs to /// </summary> /// <returns>A <see cref="Task{IRound}"/> representing the retrieval operation</returns> public async Task <IRound> GetTournamentRoundAsync() { var matchCI = (IMatchCI)SportEventCache.GetEventCacheItem(Id); if (matchCI == null) { ExecutionLog.LogDebug($"Missing data. No match cache item for id={Id}."); return(null); } var item = ExceptionStrategy == ExceptionHandlingStrategy.THROW ? await matchCI.GetTournamentRoundAsync(Cultures).ConfigureAwait(false) : await new Func <IEnumerable <CultureInfo>, Task <RoundCI> >(matchCI.GetTournamentRoundAsync).SafeInvokeAsync(Cultures, ExecutionLog, GetFetchErrorMessage("Round")).ConfigureAwait(false); return(item == null ? null : new Round(item, Cultures)); }
/// <summary> /// Asynchronously gets the list of associated <see cref="IDraw"/> /// </summary> /// <returns>A <see cref="Task{T}"/> representing an async operation</returns> public async Task <IEnumerable <IDraw> > GetDrawsAsync() { var lotteryCI = (LotteryCI)SportEventCache.GetEventCacheItem(Id); if (lotteryCI == null) { ExecutionLog.LogDebug($"Missing data. No lottery cache item for id={Id}."); return(null); } var item = ExceptionStrategy == ExceptionHandlingStrategy.THROW ? await lotteryCI.GetScheduledDrawsAsync().ConfigureAwait(false) : await new Func <Task <IEnumerable <URN> > >(lotteryCI.GetScheduledDrawsAsync).SafeInvokeAsync(ExecutionLog, GetFetchErrorMessage("ScheduledDraws")).ConfigureAwait(false); return(item.Select(selector: s => new Draw(s, SportId, SportEventCache, Cultures, ExceptionStrategy))); }
/// <summary> /// Asynchronously gets a liveOdds /// </summary> /// <returns>A liveOdds</returns> public async Task <string> GetLiveOddsAsync() { var competitionCI = (CompetitionCI)SportEventCache.GetEventCacheItem(Id); if (competitionCI == null) { ExecutionLog.LogDebug($"Missing data. No match cache item for id={Id}."); return(null); } var liveOdds = ExceptionStrategy == ExceptionHandlingStrategy.THROW ? await competitionCI.GetLiveOddsAsync().ConfigureAwait(false) : await new Func <Task <string> >(competitionCI.GetLiveOddsAsync).SafeInvokeAsync(ExecutionLog, GetFetchErrorMessage("LiveOdds")).ConfigureAwait(false); return(liveOdds); }
/// <summary> /// Asynchronously gets <see cref="T:System.Collections.Generic.IEnumerable`1" /> list of associated <see cref="T:Sportradar.OddsFeed.SDK.Entities.REST.IDrawResult" /> /// </summary> /// <returns>A <see cref="T:System.Threading.Tasks.Task`1" /> representing an async operation</returns> /// <exception cref="System.NotImplementedException"></exception> public async Task <IEnumerable <IDrawResult> > GetResultsAsync() { var drawCI = (DrawCI)SportEventCache.GetEventCacheItem(Id); if (drawCI == null) { ExecutionLog.Debug($"Missing data. No draw cache item for id={Id}."); return(null); } var item = ExceptionStrategy == ExceptionHandlingStrategy.THROW ? await drawCI.GetResultsAsync(Cultures).ConfigureAwait(false) : await new Func <IEnumerable <CultureInfo>, Task <IEnumerable <DrawResultCI> > >(drawCI.GetResultsAsync).SafeInvokeAsync(Cultures, ExecutionLog, "DrawResults").ConfigureAwait(false); return(item?.Select(s => new DrawResult(s))); }
/// <summary> /// Asynchronously gets a <see cref="ISeasonInfo"/> representing the season to which the sport event associated with the current instance belongs to /// </summary> /// <returns>A <see cref="Task{ISeasonInfo}"/> representing the retrieval operation</returns> public async Task <ISeasonInfo> GetSeasonAsync() { var matchCI = (IMatchCI)SportEventCache.GetEventCacheItem(Id); if (matchCI == null) { ExecutionLog.Debug($"Missing data. No match cache item for id={Id}."); return(null); } var item = ExceptionStrategy == ExceptionHandlingStrategy.THROW ? await matchCI.GetSeasonAsync(Cultures).ConfigureAwait(false) : await new Func <IEnumerable <CultureInfo>, Task <CacheItem> >(matchCI.GetSeasonAsync).SafeInvokeAsync(Cultures, ExecutionLog, GetFetchErrorMessage("Season")).ConfigureAwait(false); return(item == null ? null : new SeasonInfo(item.Id, item.Name)); }
/// <summary> /// Asynchronously get the <see cref="ITournamentCoverage" /> instance representing the tournament coverage associated with the current instance /// </summary> /// <returns>Task<ITournamentCoverage></returns> /// <value>The <see cref="ITournamentCoverage" /> instance representing the tournament coverage associated with the current instance</value> public async Task <ITournamentCoverage> GetTournamentCoverage() { var tournamentInfoCI = (TournamentInfoCI)SportEventCache.GetEventCacheItem(Id); if (tournamentInfoCI == null) { ExecutionLogPrivate.Debug($"Missing data. No tournament cache item for id={Id}."); return(null); } var cacheItem = ExceptionStrategy == ExceptionHandlingStrategy.CATCH ? await tournamentInfoCI.GetTournamentCoverageAsync().ConfigureAwait(false) : await new Func <Task <TournamentCoverageCI> >(tournamentInfoCI.GetTournamentCoverageAsync).SafeInvokeAsync(ExecutionLog, GetFetchErrorMessage("TournamentCoverage")).ConfigureAwait(false); return(cacheItem == null ? null : new TournamentCoverage(cacheItem)); }
/// <summary> /// Asynchronously gets <see cref="DrawStatus" /> associated with the current instance /// </summary> /// <returns>A <see cref="T:System.Threading.Tasks.Task`1" /> representing an async operation</returns> /// <exception cref="System.NotImplementedException"></exception> public async Task <DrawStatus> GetStatusAsync() { var drawCI = (DrawCI)SportEventCache.GetEventCacheItem(Id); if (drawCI == null) { ExecutionLog.Debug($"Missing data. No draw cache item for id={Id}."); return(DrawStatus.Unknown); } var item = ExceptionStrategy == ExceptionHandlingStrategy.THROW ? await drawCI.GetStatusAsync().ConfigureAwait(false) : await new Func <Task <DrawStatus> >(drawCI.GetStatusAsync).SafeInvokeAsync(ExecutionLog, "DrawStatus").ConfigureAwait(false); return(item); }
/// <summary> /// Asynchronously gets a <see cref="ISportEventConditions"/> instance representing live conditions of the sport event associated with the current instance /// </summary> /// <returns>A <see cref="Task{IVenue}"/> representing the retrieval operation</returns> /// <remarks>A Fixture is a sport event that has been arranged for a particular time and place</remarks> public async Task<ISportEventConditions> GetConditionsAsync() { var competitionCI = (CompetitionCI)SportEventCache.GetEventCacheItem(Id); if (competitionCI == null) { ExecutionLog.Debug($"Missing data. No sportEvent cache item for id={Id}."); return null; } var item = ExceptionStrategy == ExceptionHandlingStrategy.THROW ? await competitionCI.GetConditionsAsync(Cultures).ConfigureAwait(false) : await new Func<IEnumerable<CultureInfo>, Task<SportEventConditionsCI>>(competitionCI.GetConditionsAsync).SafeInvokeAsync(Cultures, ExecutionLog, GetFetchErrorMessage("EventConditions")).ConfigureAwait(false); return item == null ? null : new SportEventConditions(item, Cultures); }
/// <summary> /// Asynchronously gets a <see cref="bool"/> specifying if the tournament is exhibition game /// </summary> /// <returns>A <see cref="bool"/> specifying if the tournament is exhibition game</returns> public async Task <bool?> GetExhibitionGamesAsync() { var tournamentInfoCI = (TournamentInfoCI)SportEventCache.GetEventCacheItem(Id); if (tournamentInfoCI == null) { ExecutionLogPrivate.Debug($"Missing data. No tournament cache item for id={Id}."); return(null); } var exhibitionGames = ExceptionStrategy == ExceptionHandlingStrategy.THROW ? await tournamentInfoCI.GetExhibitionGamesAsync().ConfigureAwait(false) : await new Func <Task <bool?> >(tournamentInfoCI.GetExhibitionGamesAsync).SafeInvokeAsync(ExecutionLog, GetFetchErrorMessage("ExhibitionGames")).ConfigureAwait(false); return(exhibitionGames); }
public async Task <IEnumerable <IStage> > GetStagesAsync() { var stageCI = (StageCI)SportEventCache.GetEventCacheItem(Id); if (stageCI == null) { ExecutionLog.Debug($"Missing data. No stage cache item for id={Id}."); return(null); } var cacheItems = ExceptionStrategy == ExceptionHandlingStrategy.CATCH ? await stageCI.GetStagesAsync(Cultures).ConfigureAwait(false) : await new Func <IEnumerable <CultureInfo>, Task <IEnumerable <StageCI> > >(stageCI.GetStagesAsync) .SafeInvokeAsync(Cultures, ExecutionLog, GetFetchErrorMessage("ChildStages")).ConfigureAwait(false); return(cacheItems?.Select(c => new Stage(c.Id, GetSportAsync().Result.Id, _sportEntityFactory, SportEventCache, _sportDataCache, SportEventStatusCache, _matchStatusesCache, Cultures, ExceptionStrategy))); }
/// <summary> /// Asynchronously gets a <see cref="ILongTermEvent"/> representing the tournament to which the sport event associated with the current instance belongs to /// </summary> /// <returns>A <see cref="Task{ILongTermEvent}"/> representing the retrieval operation</returns> public async Task<ILongTermEvent> GetTournamentAsync() { var matchCI = (IMatchCI)SportEventCache.GetEventCacheItem(Id); if (matchCI == null) { ExecutionLog.Debug($"Missing data. No match cache item for id={Id}."); return null; } var tournamentId = ExceptionStrategy == ExceptionHandlingStrategy.THROW ? await matchCI.GetTournamentIdAsync(Cultures).ConfigureAwait(false) : await new Func<IEnumerable<CultureInfo>, Task<URN>>(matchCI.GetTournamentIdAsync).SafeInvokeAsync(Cultures, ExecutionLog, GetFetchErrorMessage("ILongTermEvent")).ConfigureAwait(false); return tournamentId == null ? null : _sportEntityFactory.BuildSportEvent<ILongTermEvent>(tournamentId, SportId, Cultures, ExceptionStrategy); }
/// <summary> /// Asynchronously gets a <see cref="IVenue"/> instance representing a venue where the sport event associated with the /// current instance will take place /// </summary> /// <returns>A <see cref="Task{IVenue}"/> representing the retrieval operation</returns> public async Task <IVenue> GetVenueAsync() { var competitionCI = (CompetitionCI)SportEventCache.GetEventCacheItem(Id); if (competitionCI == null) { ExecutionLog.LogDebug($"Missing data. No sportEvent cache item for id={Id}."); return(null); } var item = ExceptionStrategy == ExceptionHandlingStrategy.THROW ? await competitionCI.GetVenueAsync(Cultures).ConfigureAwait(false) : await new Func <IEnumerable <CultureInfo>, Task <VenueCI> >(competitionCI.GetVenueAsync).SafeInvokeAsync(Cultures, ExecutionLog, "Venue").ConfigureAwait(false); return(item == null ? null : new Venue(item, Cultures)); }