本文整理汇总了C#中IPackageRepository.FindPackages方法的典型用法代码示例。如果您正苦于以下问题:C# IPackageRepository.FindPackages方法的具体用法?C# IPackageRepository.FindPackages怎么用?C# IPackageRepository.FindPackages使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IPackageRepository
的用法示例。
在下文中一共展示了IPackageRepository.FindPackages方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UpdatePackageCache
/// <summary>
/// Updates the package cache by ensuring all cached packages exist in the repository.
/// </summary>
private void UpdatePackageCache(IPackageRepository repository)
{
var feedPackages = repository.FindPackages(_packagesCache.Select(p => p.Id));
var lookup = feedPackages.ToLookup(p => p.Id, StringComparer.OrdinalIgnoreCase);
_packagesCache.RemoveAll(p => !lookup.Contains(p.Id));
}
示例2: LoadPackagesFromSettingsStore
private void LoadPackagesFromSettingsStore(IPackageRepository repository)
{
// get the metadata of recent packages from registry
IEnumerable<IPersistencePackageMetadata> packagesMetadata = LoadPackageMetadataFromSettingsStore();
if (!packagesMetadata.Any())
{
return;
}
// look up the package metadata in the machine cache first before searching the aggregate repository
// this will contain the package metadata that are not found in the machine cache
var remainingMetadata = new List<IPersistencePackageMetadata>();
foreach (var metadata in packagesMetadata)
{
var cachedPackage = _cacheRepository.FindPackage(metadata.Id, metadata.Version);
if (cachedPackage != null)
{
// found a package with the same Id and Version, use it
RecentPackage package = ConvertToRecentPackage(cachedPackage, metadata.LastUsedDate);
AddRecentPackage(package);
}
else
{
// if not, put it in the remaining queue to be searched from aggregate repository
remainingMetadata.Add(metadata);
}
}
// for the remaining metadata, find packages from the Aggregate repository based on Id only
IEnumerable<IPackage> newPackages = repository.FindPackages(remainingMetadata.Select(p => p.Id));
// newPackages contains all versions of a package Id. Filter out the versions that we don't care.
IEnumerable<RecentPackage> filteredPackages = FilterPackages(remainingMetadata, newPackages);
foreach (var package in filteredPackages)
{
AddRecentPackage(package);
}
}