コード例 #1
0
        public Task <PackSourceChecker> CreatePackSourceCheckerAsync(CommandArgs config, CancellationToken cancellationToken)
        {
            List <IPackProvider> providers = new List <IPackProvider>()
            {
                new TestPackProvider(config.LocalPackagePath ?? throw new ArgumentNullException(nameof(config.LocalPackagePath)))
            };

            List <Func <IDownloadedPackInfo, PreFilterResult> > preFilterList = new List <Func <IDownloadedPackInfo, PreFilterResult> >();

            if (!config.DontFilterOnTemplateJson)
            {
                preFilterList.Add(TemplateJsonExistencePackFilter.SetupPackFilter());
            }
            preFilterList.Add(SkipTemplatePacksFilter.SetupPackFilter());
            preFilterList.Add(FilterNonMicrosoftAuthors.SetupPackFilter());

            PackPreFilterer preFilterer = new PackPreFilterer(preFilterList);

            IReadOnlyList <IAdditionalDataProducer> additionalDataProducers = new List <IAdditionalDataProducer>()
            {
                new CliHostDataProducer()
            };

            TemplateSearchCache?existingCache = LoadExistingCache(config);
            IEnumerable <FilteredPackageInfo>?knownNonTemplatePackages = LoadKnownPackagesList(config);

            return(Task.FromResult(new PackSourceChecker(providers, preFilterer, additionalDataProducers, config.SaveCandidatePacks, existingCache, knownNonTemplatePackages)));
        }
コード例 #2
0
        public async Task <PackSourceChecker> CreatePackSourceCheckerAsync(CommandArgs config, CancellationToken cancellationToken)
        {
            List <IPackProvider> providers = new List <IPackProvider>();

            if (!config.Queries.Any())
            {
                providers.AddRange(SupportedProviders.Select(kvp => new NuGetPackProvider(kvp.Key.ToString(), kvp.Value, config.OutputPath, config.PageSize, config.RunOnlyOnePage, config.IncludePreviewPacks)));
            }
            else
            {
                foreach (SupportedQueries provider in config.Queries.Distinct())
                {
                    providers.Add(new NuGetPackProvider(provider.ToString(), SupportedProviders[provider], config.OutputPath, config.PageSize, config.RunOnlyOnePage, config.IncludePreviewPacks));
                }
            }

            List <Func <IDownloadedPackInfo, PreFilterResult> > preFilterList = new List <Func <IDownloadedPackInfo, PreFilterResult> >();

            if (!config.DontFilterOnTemplateJson)
            {
                preFilterList.Add(TemplateJsonExistencePackFilter.SetupPackFilter());
            }
            preFilterList.Add(SkipTemplatePacksFilter.SetupPackFilter());
            preFilterList.Add(FilterNonMicrosoftAuthors.SetupPackFilter());

            PackPreFilterer preFilterer = new PackPreFilterer(preFilterList);

            IReadOnlyList <IAdditionalDataProducer> additionalDataProducers = new List <IAdditionalDataProducer>()
            {
                new CliHostDataProducer()
            };

            TemplateSearchCache?existingCache = config.DiffMode ? await LoadExistingCacheAsync(config, cancellationToken).ConfigureAwait(false) : null;

            IEnumerable <FilteredPackageInfo>?knownPackages = config.DiffMode ? await LoadKnownPackagesListAsync(config, cancellationToken).ConfigureAwait(false) : null;

            return(new PackSourceChecker(providers, preFilterer, additionalDataProducers, config.SaveCandidatePacks, existingCache, knownPackages));
        }