public async Task <IEnumerable <string> > Execute(string id, bool?includePrerelease)
        {
            if (string.IsNullOrWhiteSpace(id))
            {
                throw new ArgumentNullException(nameof(id));
            }

            var queryString = "id=" + Uri.EscapeUriString(id);

            if (!includePrerelease.HasValue)
            {
                queryString += "&prerelease=false";
            }
            else
            {
                queryString += "&prerelease=" + includePrerelease.Value;
            }

            var endpoints = await _serviceDiscoveryClient.GetEndpointsForResourceType(_autocompleteServiceResourceType);

            endpoints = endpoints.Select(e => new Uri(e + "?" + queryString)).AsEnumerable();

            var result = await _httpClient.GetStringAsync(endpoints);

            var resultObject = JObject.Parse(result);

            return(resultObject["data"].Select(entry => entry.ToString()));
        }
            private static async Task <string> GetFlatContainerUriAsync(Uri serviceDiscoveryUri)
            {
                var serviceDiscoveryClient = new ServiceDiscoveryClient(serviceDiscoveryUri);
                var result = await serviceDiscoveryClient.GetEndpointsForResourceType("PackageBaseAddress/3.0.0");

                return(result.First().AbsoluteUri.TrimEnd('/'));
            }
        public async Task <IEnumerable <string> > Execute(string partialId, bool?includePrerelease)
        {
            if (partialId == null)
            {
                partialId = string.Empty;
            }

            var queryString = "take=30&q=" + Uri.EscapeUriString(partialId);

            if (!includePrerelease.HasValue)
            {
                queryString += "&prerelease=false";
            }
            else
            {
                queryString += "&prerelease=" + includePrerelease.Value;
            }

            var endpoints = await _serviceDiscoveryClient.GetEndpointsForResourceType(_autocompleteServiceResourceType);

            endpoints = endpoints.Select(e => new Uri(e + "?" + queryString)).AsEnumerable();

            var result = await _httpClient.GetStringAsync(endpoints);

            var resultObject = JObject.Parse(result);

            return(resultObject["data"].Select(entry => entry.ToString()));
        }
        private async Task <string> DeprecatedExecuteQuery(string queryString)
        {
            var endpoints = await _serviceDiscoveryClient.GetEndpointsForResourceType(_autocompleteServiceResourceType);

            endpoints = endpoints.Select(e => new Uri(e + queryString)).AsEnumerable();

            return(await _httpClientToDeprecate.GetStringAsync(endpoints));
        }
        public async Task <IEnumerable <string> > RunQuery(string queryString, bool?includePrerelease)
        {
            queryString += $"&prerelease={includePrerelease ?? false}";
            var endpoints = await _serviceDiscoveryClient.GetEndpointsForResourceType(_autocompleteServiceResourceType);

            endpoints = endpoints.Select(e => new Uri(e + "?" + queryString)).AsEnumerable();

            var result = await _httpClient.GetStringAsync(endpoints);

            var resultObject = JObject.Parse(result);

            return(resultObject["data"].Select(entry => entry.ToString()));
        }
        public async Task <IEnumerable <string> > RunServiceQuery(
            string queryString,
            bool?includePrerelease,
            string semVerLevel = null)
        {
            queryString = BuildQueryString(queryString, includePrerelease, semVerLevel);

            var endpoints = await _serviceDiscoveryClient.GetEndpointsForResourceType(_autocompleteServiceResourceType);

            endpoints = endpoints.Select(e => new Uri(e + queryString)).AsEnumerable();

            var result = await _httpClient.GetStringAsync(endpoints);

            var resultObject = JObject.Parse(result);

            return(resultObject["data"].Select(entry => entry.ToString()));
        }
        public async Task <IEnumerable <string> > RunServiceQuery(
            string queryString,
            bool?includePrerelease,
            string semVerLevel = null)
        {
            queryString += $"&prerelease={includePrerelease ?? false}";

            NuGetVersion semVerLevelVersion;

            if (!string.IsNullOrEmpty(semVerLevel) && NuGetVersion.TryParse(semVerLevel, out semVerLevelVersion))
            {
                queryString += $"&semVerLevel={semVerLevel}";
            }

            var endpoints = await _serviceDiscoveryClient.GetEndpointsForResourceType(_autocompleteServiceResourceType);

            endpoints = endpoints.Select(e => new Uri(e + "?" + queryString)).AsEnumerable();

            var result = await _httpClient.GetStringAsync(endpoints);

            var resultObject = JObject.Parse(result);

            return(resultObject["data"].Select(entry => entry.ToString()));
        }