Ejemplo n.º 1
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));
        }
Ejemplo n.º 2
0
        public PackageValidator(
            IEnumerable <IAggregateValidator> aggregateValidators,
            StorageFactory auditingStorageFactory,
            ValidationSourceRepositories sourceRepositories,
            ILogger <PackageValidator> logger,
            ILogger <ValidationContext> contextLogger)
        {
            var validators = aggregateValidators?.ToList();

            if (aggregateValidators == null || !validators.Any())
            {
                throw new ArgumentException("Must supply at least one endpoint!", nameof(aggregateValidators));
            }

            AggregateValidators     = validators;
            _auditingStorageFactory = auditingStorageFactory ?? throw new ArgumentNullException(nameof(auditingStorageFactory));
            _sourceRepositories     = sourceRepositories ?? throw new ArgumentNullException(nameof(sourceRepositories));
            _logger        = logger;
            _contextLogger = contextLogger ?? throw new ArgumentNullException(nameof(contextLogger));
        }