public ValidationContext(
            PackageIdentity package,
            IEnumerable <CatalogIndexEntry> entries,
            IEnumerable <DeletionAuditEntry> deletionAuditEntries,
            IReadOnlyDictionary <FeedType, SourceRepository> feedToSource,
            CollectorHttpClient client,
            CancellationToken token,
            ILogger <ValidationContext> logger)
        {
            if (entries == null)
            {
                throw new ArgumentNullException(nameof(entries));
            }

            if (deletionAuditEntries == null)
            {
                throw new ArgumentNullException(nameof(deletionAuditEntries));
            }

            if (feedToSource == null)
            {
                throw new ArgumentNullException(nameof(feedToSource));
            }

            if (logger == null)
            {
                throw new ArgumentNullException(nameof(logger));
            }

            Package = package ?? throw new ArgumentNullException(nameof(package));
            Entries = entries.ToList();
            DeletionAuditEntries = deletionAuditEntries.ToList();
            Client            = client ?? throw new ArgumentNullException(nameof(client));
            CancellationToken = token;

            _timestampMetadataResourceV2 = feedToSource[FeedType.HttpV2].GetResource <IPackageTimestampMetadataResource>();
            _v2Resource = feedToSource[FeedType.HttpV2].GetResource <IPackageRegistrationMetadataResource>();
            _v3Resource = feedToSource[FeedType.HttpV3].GetResource <IPackageRegistrationMetadataResource>();

            var commonLogger = logger.AsCommon();

            _v2Index = new Lazy <Task <PackageRegistrationIndexMetadata> >(
                () => _v2Resource.GetIndexAsync(Package, commonLogger, CancellationToken));
            _v3Index = new Lazy <Task <PackageRegistrationIndexMetadata> >(
                () => _v3Resource.GetIndexAsync(Package, commonLogger, CancellationToken));

            _v2Leaf = new Lazy <Task <PackageRegistrationLeafMetadata> >(
                () => _v2Resource.GetLeafAsync(Package, commonLogger, CancellationToken));
            _v3Leaf = new Lazy <Task <PackageRegistrationLeafMetadata> >(
                () => _v3Resource.GetLeafAsync(Package, commonLogger, CancellationToken));

            _timestampMetadataV2 = new Lazy <Task <PackageTimestampMetadata> >(
                () => _timestampMetadataResourceV2.GetAsync(this));
        }
Esempio n. 2
0
        public ValidationContext(
            PackageIdentity package,
            IEnumerable <CatalogIndexEntry> entries,
            IEnumerable <DeletionAuditEntry> deletionAuditEntries,
            ValidationSourceRepositories sourceRepositories,
            CollectorHttpClient client,
            CancellationToken token,
            ILogger <ValidationContext> logger)
        {
            if (deletionAuditEntries == null)
            {
                throw new ArgumentNullException(nameof(deletionAuditEntries));
            }

            if (sourceRepositories == null)
            {
                throw new ArgumentNullException(nameof(sourceRepositories));
            }

            Package = package ?? throw new ArgumentNullException(nameof(package));
            Entries = entries?.ToList();
            DeletionAuditEntries = deletionAuditEntries.ToList();
            Client            = client ?? throw new ArgumentNullException(nameof(client));
            CancellationToken = token;
            _logger           = logger ?? throw new ArgumentNullException(nameof(logger));
            _commonLogger     = logger.AsCommon();

            _databasetimestampMetadataResource           = sourceRepositories.V2.GetResource <IPackageTimestampMetadataResource>();
            _databasePackageRegistrationMetadataResource = sourceRepositories.V2.GetResource <IPackageRegistrationMetadataResource>();
            _v3PackageRegistrationMetadataResource       = sourceRepositories.V3.GetResource <IPackageRegistrationMetadataResource>();
            _httpSourceResource = sourceRepositories.V3.GetResource <HttpSourceResource>();

            _databaseIndex = new Lazy <Task <PackageRegistrationIndexMetadata> >(
                () => _databasePackageRegistrationMetadataResource.GetIndexAsync(Package, _commonLogger, CancellationToken));
            _v3Index = new Lazy <Task <PackageRegistrationIndexMetadata> >(
                () => _v3PackageRegistrationMetadataResource.GetIndexAsync(Package, _commonLogger, CancellationToken));

            _databaseLeaf = new Lazy <Task <PackageRegistrationLeafMetadata> >(
                () => _databasePackageRegistrationMetadataResource.GetLeafAsync(Package, _commonLogger, CancellationToken));
            _v3Leaf = new Lazy <Task <PackageRegistrationLeafMetadata> >(
                () => _v3PackageRegistrationMetadataResource.GetLeafAsync(Package, _commonLogger, CancellationToken));

            _timestampMetadataDatabase = new Lazy <Task <PackageTimestampMetadata> >(
                () => _databasetimestampMetadataResource.GetAsync(this));
        }
Esempio n. 3
0
 protected async Task <PackageRegistrationIndexMetadata> GetIndexAsync(
     IPackageRegistrationMetadataResource resource,
     ValidationContext context)
 {
     return(await resource.GetIndexAsync(context.Package, Logger.AsCommon(), context.CancellationToken));
 }