コード例 #1
0
        public async Task <RaceTable> GetQualifyingResultAsync(string season = "current", int round = 1)
        {
            RaceRootObject data = null;

            var            url      = string.Format("http://ergast.com/api/f1/{0}/{1}/qualifying.json", season, round);
            HttpWebRequest request  = WebRequest.CreateHttp(new Uri(url));
            var            response = await HttpRequest(request);

            if (response != null)
            {
                data = JsonConvert.DeserializeObject <RaceRootObject>(response);
            }

            return(data != null ? data.MRData.RaceTable : null);
        }
コード例 #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="season"></param>
        /// <returns></returns>
        public async Task <RaceTable> GetSeasonScheduleCollectionAsync(string season = "current")
        {
            RaceRootObject result = null;

            var            url      = string.Format("http://ergast.com/api/f1/{0}.json", season);
            HttpWebRequest request  = WebRequest.CreateHttp(new Uri(url));
            var            response = await HttpRequest(request);

            if (response != null)
            {
                result = JsonConvert.DeserializeObject <RaceRootObject>(response);
            }

            return(result != null ? result.MRData.RaceTable : null);
        }
コード例 #3
0
ファイル: CircuitService.cs プロジェクト: rubenrovira/Events
        public async Task <CircuitTable> GetSeasonCircuitsCollectionAsync(string season = "current")
        {
            RaceRootObject data = null;
            var            url  = string.Format("http://ergast.com/api/f1/{0}/circuits.json", season);

            HttpWebRequest request  = WebRequest.CreateHttp(new Uri(url));
            var            response = await HttpRequest(request);

            if (response != null)
            {
                data = JsonConvert.DeserializeObject <RaceRootObject>(response);
            }

            return(data != null ? data.MRData.CircuitTable : null);
        }
コード例 #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="driver"></param>
        /// <param name="season"></param>
        /// <returns></returns>
        public async Task <RaceTable> GetDriverResultsAsync(string driver = "", string season = "current")
        {
            RaceRootObject data = null;
            string         url  = string.Format("http://ergast.com/api/f1/{0}/drivers/{1}/results.json", season, driver);

            HttpWebRequest request  = WebRequest.CreateHttp(new Uri(url));
            var            response = await HttpRequest(request);

            if (response != null)
            {
                data = JsonConvert.DeserializeObject <RaceRootObject>(response);
            }

            return(data != null ? data.MRData.RaceTable : null);
        }
コード例 #5
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public async Task <DriverTable> GetChampionCollectionAsync()
        {
            RaceRootObject data = null;
            const string   url  = "http://ergast.com/api/f1/driverStandings/1/drivers.json";

            HttpWebRequest request  = WebRequest.CreateHttp(new Uri(url));
            var            response = await HttpRequest(request);

            if (response != null)
            {
                data = JsonConvert.DeserializeObject <RaceRootObject>(response);
            }

            return(data != null ? data.MRData.DriverTable : null);
        }
コード例 #6
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="driver"></param>
        /// <returns></returns>
        public async Task <DriverTable> GetDriverInformationAsync(string driver = "")
        {
            RaceRootObject data = null;
            var            url  = string.Format("http://ergast.com/api/f1/drivers/{0}.json", driver);

            HttpWebRequest request  = WebRequest.CreateHttp(new Uri(url));
            var            response = await HttpRequest(request);

            if (response != null)
            {
                data = JsonConvert.DeserializeObject <RaceRootObject>(response);
            }

            return(data != null ? data.MRData.DriverTable : null);
        }