Beispiel #1
0
        public async Task <FlatContainerIndex> GetIndexAsync(string baseUrl, string id)
        {
            var lowerId    = id.ToLowerInvariant();
            var packageUrl = $"{baseUrl.TrimEnd('/')}/{lowerId}/index.json";

            return(await _httpSource.DeserializeUrlAsync <FlatContainerIndex>(packageUrl, ignoreNotFounds : true, logger : _logger));
        }
        public async Task <SearchDiagnostics> GetDiagnosticsAsync(string baseUrl)
        {
            var url = $"{baseUrl.TrimEnd('/')}/search/diag";

            try
            {
                return(await _httpSource.DeserializeUrlAsync <SearchDiagnostics>(
                           url,
                           ignoreNotFounds : false,
                           maxTries : 1,
                           logger : _logger));
            }
            catch
            {
                _invalidator.InvalidateCache();
                throw;
            }
        }
 public static Task <T> DeserializeUrlAsync <T>(
     this HttpSource httpSource,
     string url,
     bool ignoreNotFounds,
     ILogger logger)
 {
     return(httpSource.DeserializeUrlAsync <T>(
                url,
                ignoreNotFounds,
                maxTries: 3,
                logger: logger));
 }
Beispiel #4
0
        public async Task <AutocompleteIdResults> GetIdsAsync(string q, int?skip, int?take, bool?prerelease, string semVerLevel)
        {
            var queryString = new Dictionary <string, string>();

            if (q != null)
            {
                queryString["q"] = q;
            }

            if (skip.HasValue)
            {
                queryString["skip"] = skip.Value.ToString();
            }

            if (take.HasValue)
            {
                queryString["take"] = take.ToString();
            }

            if (prerelease.HasValue)
            {
                queryString["prerelease"] = prerelease.Value ? "true" : "false";
            }

            if (semVerLevel != null)
            {
                queryString["semVerLevel"] = semVerLevel;
            }

            var baseUrl = await _serviceIndexCache.GetUrlAsync(ServiceIndexTypes.Autocomplete);

            var url = QueryHelpers.AddQueryString(baseUrl, queryString);

            return(await _httpSource.DeserializeUrlAsync <AutocompleteIdResults>(
                       url,
                       ignoreNotFounds : false,
                       logger : _logger));
        }