本文整理汇总了C#中IPackageRepository.GetPackages方法的典型用法代码示例。如果您正苦于以下问题:C# IPackageRepository.GetPackages方法的具体用法?C# IPackageRepository.GetPackages怎么用?C# IPackageRepository.GetPackages使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IPackageRepository
的用法示例。
在下文中一共展示了IPackageRepository.GetPackages方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: VirtualRepository
public VirtualRepository(IPackageRepository repo)
{
_packages = new HashSet<IPackage>(PackageEqualityComparer.IdAndVersion);
if (repo != null)
{
_packages.AddRange(repo.GetPackages());
}
}
示例2: PackageServiceTests
public PackageServiceTests()
{
_packageRepository = A.Fake<IPackageRepository>(opts =>
{
opts.Strict();
});
A.CallTo(() => _packageRepository.GetPackages()).Returns(new[]
{
new DataModel.Package { Id = _packageId, Title = "Some Package" },
new DataModel.Package { Id = "second.package", Title = "Second Package" }
});
_SUT = new PackageService(_packageRepository, A.Dummy<IConnectionStringRepository>(), A.Dummy<IPackageSettingRepository>(), A.Dummy<ServiceModel.IHoardeManager>());
}
示例3: 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();
}
示例4: GetPackagesByDependencyOrder
/// <summary>
/// Get all packages from the specified repository in the dependency order,
/// e.g. if A -> B, then B will come before A.
/// </summary>
public IEnumerable<IPackage> GetPackagesByDependencyOrder(IPackageRepository repository)
{
if (repository == null) {
throw new ArgumentNullException("repository");
}
Marker.Clear();
_repository = repository;
_sortedPackages = new List<IPackage>();
foreach (var package in _repository.GetPackages()) {
Walk(package);
}
return _sortedPackages;
}
示例5: GetPackageIdsFromLocalPackageRepository
private static IEnumerable<string> GetPackageIdsFromLocalPackageRepository(IPackageRepository packageRepository,string searchFilter,bool includePrerelease)
{
IEnumerable<IPackage> packages = packageRepository.GetPackages();
if (!String.IsNullOrEmpty(searchFilter))
{
packages = packages.Where(p => p.Id.StartsWith(searchFilter, StringComparison.OrdinalIgnoreCase));
}
if (!includePrerelease)
{
packages = packages.Where(p => p.IsReleaseVersion());
}
return packages.Select(p => p.Id)
.Distinct()
.Take(30);
}
示例6: GetPackages
internal static IQueryable<IPackage> GetPackages(IPackageRepository repository, bool filterTags)
{
var packages = repository.GetPackages();
return GetPackages(packages, filterTags);
}
示例7: GetPackages
private IEnumerable<IPackage> GetPackages(IPackageRepository repository)
{
var packages = repository.GetPackages();
if (Id.Any())
{
var packageIdSet = new HashSet<string>(packages.Select(r => r.Id), StringComparer.OrdinalIgnoreCase);
var idSet = new HashSet<string>(Id, StringComparer.OrdinalIgnoreCase);
var invalid = Id.Where(id => !packageIdSet.Contains(id));
if (invalid.Any())
{
throw new CommandLineException(LocalizedResourceManager.GetString("UnableToFindPackages"), String.Join(", ", invalid));
}
packages = packages.Where(r => idSet.Contains(r.Id));
}
var packageSorter = new PackageSorter(targetFramework: null);
return packageSorter.GetPackagesByDependencyOrder(new ReadOnlyPackageRepository(packages)).Reverse();
}
示例8: CheckSource
public static bool CheckSource(IPackageRepository repository)
{
try
{
repository.GetPackages().FirstOrDefault();
return true;
}
catch (Exception ex)
{
if (!IsSourceUnavailableException(ex))
{
throw;
}
}
return false;
}
示例9: GetPackageVersionsFromLocalPackageRepository
protected IEnumerable<NuGetVersion> GetPackageVersionsFromLocalPackageRepository(IPackageRepository packageRepository, string packageId, string versionPrefix, bool includePrerelease)
{
var packages = packageRepository.GetPackages().Where(p => p.Id.Equals(packageId, StringComparison.OrdinalIgnoreCase));
if (!includePrerelease)
{
packages = packages.Where(p => p.IsReleaseVersion());
}
var versions = packages.Select(p => p.Version.ToString()).ToList();
versions = versions.Where(item => item.StartsWith(versionPrefix, StringComparison.OrdinalIgnoreCase)).ToList();
return versions.Select(item => NuGetVersion.Parse(item));
}
示例10: GetPackageList
private IQueryable<IPackage> GetPackageList(IPackageRepository repository)
{
IQueryable<IPackage> packages;
if (AllVersions)
{
packages = repository.GetPackages();
}
else
{
packages = repository.GetPackages().Where(p => p.IsLatestVersion);
}
return packages;
}
示例11: GetPackages
protected virtual IQueryable<IPackage> GetPackages(IPackageRepository sourceRepository)
{
bool effectiveIncludePrerelease = IncludePrerelease || !UseRemoteSource;
IQueryable<IPackage> packages = String.IsNullOrEmpty(Filter)
? sourceRepository.GetPackages()
: sourceRepository.Search(Filter, effectiveIncludePrerelease);
// by default, sort packages by Id
packages = packages.OrderBy(p => p.Id);
return packages;
}
示例12: GetPackages
internal static IQueryable<IPackage> GetPackages(IPackageRepository repository, string searchTerm)
{
return GetPackages(repository.GetPackages(), searchTerm);
}
示例13: Build
public void Build(IPackageRepository localRepository) {
if (this.IsCacheBuildable() == true) {
foreach (RepositoryModel repository in this.Repositories.Where(repository => String.IsNullOrEmpty(repository.Uri) == false)) {
var cache = new List<PackageWrapperModel>();
repository.CacheStamp = DateTime.Now;
try {
var query = this.GetCachedSourceRepository(repository.Uri).GetPackages().Where(package => package.IsLatestVersion == true);
Defines.PackageRequiredTags.ForEach(tag => query = query.Where(package => package.Tags != null && package.Tags.Contains(tag)));
// Append all available packages for this repository.
new AvailableCacheBuilder() {
Cache = cache,
Source = query.ToList()
.OrderByDescending(pack => pack.Version)
.ToList()
}.Build();
// Update all available packages with those that are installed.
new InstalledCacheBuilder() {
Cache = cache,
Source = localRepository
.GetPackages()
.ToList()
}.Build();
// No errors occured during fetch, null it out.
repository.CacheError = null;
repository.Packages = cache;
}
catch (Exception e) {
// Record the error that occured while fetching the packages.
repository.CacheError = e.Message;
}
}
// A list of package id's that we know the source of
IEnumerable<String> availablePackageIds = this.Repositories.SelectMany(repository => repository.Packages).Select(packageWrapper => packageWrapper.Id);
// Now orphan all remaining packages that are installed but do not belong to any repository.
new OrphanedCacheBuilder() {
Cache = this.Repositories.First(repository => repository.IsOrphanage == true).Packages,
Source = localRepository
.GetPackages()
.Where(package => availablePackageIds.Contains(package.Id) == false)
.ToList()
}.Build();
this.RebuiltTime = DateTime.Now;
}
}
示例14: GetPackages
protected virtual IQueryable<IPackage> GetPackages(IPackageRepository sourceRepository)
{
IQueryable<IPackage> packages = null;
if (String.IsNullOrEmpty(Filter))
{
packages = sourceRepository.GetPackages();
}
else
{
packages = sourceRepository.Search(Filter, IncludePrerelease);
}
// for recent packages, we want to order by last installed first instead of Id
if (!Recent.IsPresent)
{
packages = packages.OrderBy(p => p.Id);
}
return packages;
}
示例15: GetPackages
private IEnumerable<IPackage> GetPackages(IPackageRepository repository)
{
var packages = repository.GetPackages();
if (Id.Any())
{
var packageIdSet = new HashSet<string>(packages.Select(r => r.Id), StringComparer.OrdinalIgnoreCase);
var idSet = new HashSet<string>(Id, StringComparer.OrdinalIgnoreCase);
var invalid = Id.Where(id => !packageIdSet.Contains(id));
if (invalid.Any())
{
throw new BuildException(String.Format("Unable to find packages {0}", String.Join(", ", invalid)), Location);
}
packages = packages.Where(r => idSet.Contains(r.Id));
}
var packageSorter = new PackageSorter(targetFramework: null);
return packageSorter.GetPackagesByDependencyOrder(new ReadOnlyPackageRepository(packages)).Reverse();
}