예제 #1
0
        /// <summary>
        /// Find-Package bases on the given package Id
        /// </summary>
        /// <param name="packageId">Package Id</param>
        /// <param name="request"></param>
        /// <returns></returns>
        public IEnumerable <IPackage> FindPackagesById(string packageId, NuGetRequest request)
        {
            request.Debug(Messages.DebugInfoCallMethod3, "HttpClientPackageRepository", "FindPackagesById", packageId);

            var query = packageId.MakeFindPackageByIdQuery(_nugetFindPackageIdQueryFormat);

            //request.Verbose(query.ToString());

            return(NuGetClient.FindPackage(query, request));
        }
예제 #2
0
        /// <summary>
        /// Find-Package
        /// </summary>
        /// <param name="packageId">package Id</param>
        /// <param name="version">package version</param>
        /// <param name="request"></param>
        /// <returns></returns>
        public IPackage FindPackage(string packageId, SemanticVersion version, NuGetRequest request)
        {
            if (string.IsNullOrWhiteSpace(packageId))
            {
                return(null);
            }

            request.Debug(Messages.DebugInfoCallMethod3, "HttpClientPackageRepository", "FindPackage", packageId);

            var query = packageId.MakeFindPackageByIdQuery(_nugetFindPackageIdQueryFormat);

            var packages = NuGetClient.FindPackage(query, request);

            //Usually versions has a limited number, ToArray should be ok.
            var versions = version.GetComparableVersionStrings().ToArray();

            //Will only enumerate packages once
            return(packages.FirstOrDefault(package => packageId.Equals(package.Id, StringComparison.OrdinalIgnoreCase) && versions.Contains(package.Version, StringComparer.OrdinalIgnoreCase)));
        }
        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));
        }