Пример #1
0
        public async Task <IActionResult> GetRawDataAsync()
        {
            try
            {
                var data = await _dataFetcher.GetData();

                return(Ok(data));
            }
            catch (Exception e)
            {
                return(HandleException(e));
            }
        }
Пример #2
0
        /// <summary>
        /// Gets a <see cref="!:T" /> instance in language specified by the provided <code>languageCode</code>
        /// </summary>
        /// <param name="languageCode">A two letter language code of the <see cref="T:System.Globalization.CultureInfo" /></param>
        /// <returns>A <see cref="T:System.Threading.Tasks.Task`1" /> representing the async operation</returns>
        public new virtual BookmakerDetailsDTO GetData(string languageCode)
        {
            var uri    = GetRequestUri(languageCode);
            var stream = _fetcher.GetData(uri);
            var bookmakerDetailsDTO = _mapperFactory.CreateMapper(_deserializer.Deserialize(stream)).Map();

            bookmakerDetailsDTO.ServerTimeDifference = TimeSpan.Zero;

            var httpDataFetcher = _fetcher as HttpDataFetcher;

            if (httpDataFetcher != null)
            {
                IEnumerable <string> x;
                if (httpDataFetcher.ResponseHeaders != null && httpDataFetcher.ResponseHeaders.TryGetValue("Date", out x))
                {
                    var date = SdkInfo.ParseDate(x.FirstOrDefault());
                    if (date != null)
                    {
                        bookmakerDetailsDTO.ServerTimeDifference = DateTime.Now - date.Value;
                    }
                }
            }

            return(bookmakerDetailsDTO);
        }
Пример #3
0
        public void PrintReport()
        {
            string data     = _dataFetcher.GetData();
            string document = _documentFormatter.FormatDocument(data);

            Console.WriteLine(document);
        }
Пример #4
0
        public decimal CalcFoo(IDataFetcher df)
        {
            var data   = df.GetData();
            var result = data.Take(100).Average();

            return(result);
        }
Пример #5
0
        /// <summary>
        /// Fetches and deserializes the data from the provided <see cref="Uri"/>
        /// </summary>
        /// <param name="uri">A <see cref="Uri"/> specifying the data location</param>
        /// <returns>A <see cref="Task{T}"/> representing the ongoing operation</returns>
        protected T GetDataInternal(Uri uri)
        {
            Guard.Argument(uri, nameof(uri)).NotNull();

            var stream = _fetcher.GetData(uri);

            return(_deserializer.Deserialize(stream));
        }
        /// <summary>
        ///     Fetches and deserializes the data from the provided <see cref="Uri" />
        /// </summary>
        /// <param name="uri">A <see cref="Uri" /> specifying the data location</param>
        /// <returns>A <see cref="Task{T}" /> representing the ongoing operation</returns>
        protected T GetDataInternal(Uri uri)
        {
            Contract.Requires(uri != null);

            var stream = _fetcher.GetData(uri);

            return(_deserializer.Deserialize(stream));
        }
Пример #7
0
        /// <summary>
        /// Fetches and deserializes the data from the provided <see cref="Uri"/>.
        /// </summary>
        /// <param name="uri">A <see cref="Uri"/> specifying the data location</param>
        /// <returns>A <see cref="Task{T}"/> representing the ongoing operation</returns>
        protected TOut GetDataInternal(Uri uri)
        {
            Guard.Argument(uri, nameof(uri)).NotNull();

            var stream = _fetcher.GetData(uri);
            var item   = _deserializer.Deserialize(stream);

            DispatchReceivedRawApiData(uri, item);
            return(_mapperFactory.CreateMapper(item).Map());
        }
Пример #8
0
        /// <summary>
        ///     Fetches and deserializes the data from the provided <see cref="Uri" />.
        /// </summary>
        /// <param name="uri">A <see cref="Uri" /> specifying the data location</param>
        /// <returns>A <see cref="Task{T}" /> representing the ongoing operation</returns>
        protected TOut GetDataInternal(Uri uri)
        {
            Contract.Requires(uri != null);

            var stream = _fetcher.GetData(uri);
            var item   = _deserializer.Deserialize(stream);

            DispatchReceivedRawApiData(uri, item);
            return(_mapperFactory.CreateMapper(item).Map());
        }
        /// <summary>
        /// Fetches and deserializes the data from the provided <see cref="Uri"/>.
        /// </summary>
        /// <param name="uri">A <see cref="Uri"/> specifying the data location</param>
        /// <param name="requestParams">The parameters associated with the request (if present)</param>
        /// <param name="culture">The language associated with the request</param>
        /// <returns>A <see cref="Task{T}"/> representing the ongoing operation</returns>
        protected TOut GetDataInternal(Uri uri, string requestParams, string culture)
        {
            Guard.Argument(uri, nameof(uri)).NotNull();

            var stopWatch = new Stopwatch();

            stopWatch.Start();
            var stream = _fetcher.GetData(uri);
            var item   = _deserializer.Deserialize(stream);

            stopWatch.Stop();
            DispatchReceivedRawApiData(uri, item, requestParams, TimeSpan.FromMilliseconds(stopWatch.ElapsedMilliseconds), culture);
            return(_mapperFactory.CreateMapper(item).Map());
        }
        private EntityList <NamedValueDTO> GetDescriptionsInternal(Uri uri)
        {
            var stream = _fetcher.GetData(uri);

            return(GetDescriptions(stream, uri));
        }