本文整理汇总了C#中IPackageRepository.FindPackagesById方法的典型用法代码示例。如果您正苦于以下问题:C# IPackageRepository.FindPackagesById方法的具体用法?C# IPackageRepository.FindPackagesById怎么用?C# IPackageRepository.FindPackagesById使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IPackageRepository
的用法示例。
在下文中一共展示了IPackageRepository.FindPackagesById方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetPackagesToOpen
protected IEnumerable<FileSystemPath> GetPackagesToOpen(IPackageRepository repository, string id, string version, bool recurse)
{
List<FileSystemPath> returnValue = new List<FileSystemPath>();
var package = repository.FindPackage(id, new NuGet.SemanticVersion(version));
if (package != null)
{
returnValue.Add(new FileSystemPath(RetrieveTemporaryPackageFile(package)));
if (recurse)
{
foreach (var dependency in Enumerable.SelectMany(package.DependencySets, d => d.Dependencies))
{
var childPackages = repository.FindPackagesById(dependency.Id);
var childPackage = childPackages.FindByVersion(dependency.VersionSpec).FirstOrDefault();
if (childPackage != null)
{
returnValue.AddRange(GetPackagesToOpen(repository, childPackage.Id, childPackage.Version.ToString(), recurse));
}
}
}
}
return returnValue;
}
示例2: GetPackages
protected override IQueryable<IPackage> GetPackages(IPackageRepository sourceRepository)
{
IQueryable<IPackage> packages;
if (!String.IsNullOrEmpty(Filter))
{
if (ExactMatch)
{
packages = sourceRepository.FindPackagesById(Filter).AsQueryable();
}
else
{
packages = sourceRepository.GetPackages()
.Where(p => p.Id.ToLower().StartsWith(Filter.ToLower()));
}
}
else
{
packages = sourceRepository.GetPackages();
}
return packages.OrderByDescending(p => p.DownloadCount)
.ThenBy(p => p.Id)
.AsQueryable();
}
示例3: matchPackage
IPackage matchPackage(IPackageRepository packageRepository, string id, IVersionSpec version)
{
return packageRepository.FindPackagesById(id).FirstOrDefault(x => VersionComparer.Matches(version, x.Version));
}
示例4: ResolveDependencyCore
public static IPackage ResolveDependencyCore(
IPackageRepository repository,
PackageDependency dependency,
IPackageConstraintProvider constraintProvider,
bool allowPrereleaseVersions,
bool preferListedPackages,
DependencyVersion dependencyVersion)
{
if (repository == null)
{
throw new ArgumentNullException("repository");
}
if (dependency == null)
{
throw new ArgumentNullException("dependency");
}
IEnumerable<IPackage> packages = repository.FindPackagesById(dependency.Id).ToList();
// Always filter by constraints when looking for dependencies
packages = FilterPackagesByConstraints(constraintProvider, packages, dependency.Id, allowPrereleaseVersions);
IList<IPackage> candidates = packages.ToList();
if (preferListedPackages)
{
// pick among Listed packages first
IPackage listedSelectedPackage = ResolveDependencyCore(
candidates.Where(PackageExtensions.IsListed),
dependency,
dependencyVersion);
if (listedSelectedPackage != null)
{
return listedSelectedPackage;
}
}
return ResolveDependencyCore(candidates, dependency, dependencyVersion);
}
示例5: GetLastestPackageVersion
/// <summary>
/// Find the latest version of a package in the given repo.
/// </summary>
/// <param name="repo">The repository where to find the latest version of the package.</param>
/// <param name="id">The id of the package.</param>
/// <param name="allowPrereleaseVersions">Indicates if prerelease version is allowed.</param>
/// <returns>the latest version of the package; or null if the package doesn't exist
/// in the repo.</returns>
private static IPackage GetLastestPackageVersion(IPackageRepository repo, string id, bool allowPrereleaseVersions)
{
IPackage latestVersion = null;
var latestPackageLookup = repo as ILatestPackageLookup;
if (latestPackageLookup != null &&
latestPackageLookup.TryFindLatestPackageById(id, allowPrereleaseVersions, out latestVersion))
{
return latestVersion;
}
var aggregateRepository = repo as AggregateRepository;
if (aggregateRepository != null)
{
return GetLatestVersionPackageByIdFromAggregateRepository(
aggregateRepository, id, allowPrereleaseVersions);
}
IEnumerable<IPackage> packages = repo.FindPackagesById(id).OrderByDescending(p => p.Version);
if (!allowPrereleaseVersions)
{
packages = packages.Where(p => p.IsReleaseVersion());
}
latestVersion = packages.FirstOrDefault();
return latestVersion;
}
示例6: RunAuditAndReturnResults
private List<PackageAuditResult> RunAuditAndReturnResults(IPackageRepository repository, FeedAuditor feedAuditor)
{
List<PackageAuditResult> results = null;
if (String.IsNullOrEmpty(Package))
results = feedAuditor.Audit();
else
{
var actualPackage = File.Exists(Package) ? new ZipPackage(Package) : repository.FindPackagesById(Package).FirstOrDefault();
if (actualPackage != null)
results = feedAuditor.Audit(actualPackage);
else
throw new ApplicationException(string.Format("Could not find package locally or on feed: {0}", Package));
}
return results;
}
示例7: FindLatestInstalledPackage
private IPackage FindLatestInstalledPackage(IPackageRepository packageRepository)
{
return packageRepository.FindPackagesById(mainPackage).OrderByDescending(p => p.Version).FirstOrDefault();
}
示例8: FindPackage
private IPackage FindPackage(IPackageRepository repository, string packageId, SemanticVersion version, IPackageConstraintProvider constraintProvider,
bool allowPrereleaseVersions, bool allowUnlisted)
{
if (repository == null)
{
throw new ArgumentNullException("repository");
}
if (packageId == null)
{
throw new ArgumentNullException("packageId");
}
// if an explicit version is specified, disregard the 'allowUnlisted' argument
// and always allow unlisted packages.
if (version != null)
{
allowUnlisted = true;
}
IEnumerable<IPackage> packages = repository.FindPackagesById(packageId);
_cache.AddCacheEntryByList(packageId, packages);
if (!allowUnlisted)
{
packages = packages.Where(PackageExtensions.IsListed);
}
if (version != null)
{
packages = packages.Where(p => p.Version == version);
}
else if (constraintProvider != null)
{
packages = FilterPackagesByConstraints(constraintProvider, packages, packageId, allowPrereleaseVersions);
}
return packages.FirstOrDefault();
}