コード例 #1
0
        public NuGetSearchResult Find(NuGetSearchContext findContext, RequestWrapper request)
        {
            request.Debug(Messages.DebugInfoCallMethod3, "NuGetPackageFeed3", "Find", findContext.PackageInfo.Id);
            if (System.Management.Automation.WildcardPattern.ContainsWildcardCharacters(findContext.PackageInfo.Id))
            {
                // Short circuit when there's wildcards - this will never work
                return(findContext.MakeResult(new List <IPackage>()));
            }

            NuGetSearchResult result = findContext.MakeResult(FindImpl(findContext, request), versionPostFilterRequired: false);

            request.Debug(Messages.DebugInfoReturnCall, "NuGetPackageFeed3", "Find");
            return(result);
        }
コード例 #2
0
        public NuGetSearchResult Search(NuGetSearchContext searchContext, RequestWrapper request)
        {
            request.Debug(Messages.DebugInfoCallMethod, "NuGetSearchFeed2", "Search");
            if (request == null)
            {
                return(searchContext.MakeResult());
            }

            string searchString = this.ResourcesCollection.GetSearchQueryDelegate(searchContext.SearchTerms);

            request.Debug(Messages.DebugInfoCallMethod3, "NuGetSearchFeed2", "Search", searchString);

            var searchQuery = searchString.MakeSearchQuery(this.baseUrl, searchContext.AllowPrerelease, searchContext.AllVersions);

            return(searchContext.MakeResult(NuGetWebUtility.SendRequest(searchQuery, request)));
        }
コード例 #3
0
        /// <summary>
        /// Search the entire repository for the case when a user does not provider package name or uses wildcards in the name.
        /// </summary>
        /// <param name="searchTerm">The Searchterm</param>
        /// <param name="nugetRequest"></param>
        /// <returns></returns>
        public NuGetSearchResult Search(NuGetSearchContext searchContext, NuGetRequest nugetRequest)
        {
            var packages = SearchImpl(this.ResourceProvider.GetSearchQueryDelegate(searchContext.SearchTerms), nugetRequest);

            if (packages == null)
            {
                return(searchContext.MakeResult(Enumerable.Empty <IPackage>()));
            }

            if (nugetRequest != null && nugetRequest.AllVersions.Value)
            {
                //return whatever we can find
                return(searchContext.MakeResult(packages));
            }

            //return the latest version
            return(searchContext.MakeResult(packages.GroupBy(p => p.Id).Select(each => each.OrderByDescending(pp => pp.Version).FirstOrDefault())));
        }
コード例 #4
0
        public NuGetSearchResult Search(NuGetSearchContext searchContext, NuGetRequest nugetRequest)
        {
            nugetRequest.Debug(Messages.DebugInfoCallMethod, "NuGetSearchFeed2", "Search");
            if (nugetRequest == null)
            {
                return(searchContext.MakeResult());
            }

            return(Search(searchContext, new RequestWrapper(nugetRequest)));
        }
コード例 #5
0
        public NuGetSearchResult Search(NuGetSearchContext searchContext, RequestWrapper request)
        {
            // This is a search scenario, so it should be safe to skip some metadata for the sake of performance
            searchContext.EnableDeepMetadataBypass = true;
            return(base.Execute <NuGetSearchResult>((baseUrl) =>
            {
                // For now we'll just get all versions and return the latest
                HttpQueryBuilder qb = new HttpQueryBuilder();
                // Once searchTermQb encodes the searchTerm, don't encode the ":" part of the resulting string
                qb.Add(Constants.QueryQueryParam, this.ResourcesCollection.GetSearchQueryDelegate(searchContext.SearchTerms), separator: "=", encode: false).Add(Constants.TakeQueryParam, Constants.SearchPageCount)
                .Add(Constants.SemVerLevelQueryParam, Constants.SemVerLevel2);
                if (searchContext.AllowPrerelease)
                {
                    qb.Add(Constants.PrereleaseQueryParam, "true");
                }

                NuGetSearchTerm searchTerm = searchContext.SearchTerms.Where(st => st.Term == NuGetSearchTerm.NuGetSearchTermType.SearchTerm).FirstOrDefault();
                IEnumerable <IPackage> packages = SearchPackagesWithBackup(baseUrl, qb, request, searchContext, searchTerm);

                return searchContext.MakeResult(packages, versionPostFilterRequired: true, namePostFilterRequired: false, containsPostFilterRequired: false);
            }));
        }
コード例 #6
0
        public NuGetSearchResult Find(NuGetSearchContext findContext, RequestWrapper request)
        {
            if (string.IsNullOrWhiteSpace(findContext.PackageInfo.Id))
            {
                return(null);
            }

            request.Debug(Messages.DebugInfoCallMethod3, "NuGetPackageFeed2", "FindPackage", findContext.PackageInfo.Id);

            var query = findContext.PackageInfo.Id.MakeFindPackageByIdQuery(this.nugetFindPackageIdQueryFormat);

            var packages = NuGetClient.FindPackage(query, request).Where(package => findContext.PackageInfo.Id.Equals(package.Id, StringComparison.OrdinalIgnoreCase));

            if (findContext.RequiredVersion != null)
            {
                //Usually versions has a limited number, ToArray should be ok.
                var versions = findContext.RequiredVersion.GetComparableVersionStrings().ToArray();
                packages = packages.Where(package => versions.Contains(package.Version, StringComparer.OrdinalIgnoreCase));
            }

            //Will only enumerate packages once
            return(findContext.MakeResult(packages));
        }
コード例 #7
0
        /// <summary>
        /// Find-Package based the given Id
        /// </summary>
        /// <param name="packageId">Package Id</param>
        /// <param name="request"></param>
        /// <returns></returns>
        public NuGetSearchResult FindPackagesById(NuGetSearchContext findContext, NuGetRequest request)
        {
            IEnumerable <IPackage> packages = FindPackagesById(OpenPackage, findContext.PackageInfo.Id, request);

            return(findContext.MakeResult(packages));
        }