当前位置: 首页>>代码示例>>C#>>正文


C# IPackageRepository.FindPackages方法代码示例

本文整理汇总了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));
 }
开发者ID:xero-github,项目名称:Nuget,代码行数:9,代码来源:RecentPackagesRepository.cs

示例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);
            }
        }
开发者ID:xero-github,项目名称:Nuget,代码行数:41,代码来源:RecentPackagesRepository.cs


注:本文中的IPackageRepository.FindPackages方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。