예제 #1
0
        public static PackageValidator CreatePackageValidator(
            string galleryUrl,
            string indexUrl,
            StorageFactory auditingStorageFactory,
            ValidatorConfiguration validatorConfig,
            EndpointConfiguration endpointConfig,
            Func <HttpMessageHandler> messageHandlerFactory,
            IGalleryDatabaseQueryService galleryDatabase,
            ILoggerFactory loggerFactory)
        {
            if (auditingStorageFactory == null)
            {
                throw new ArgumentNullException(nameof(auditingStorageFactory));
            }

            var collection = new ServiceCollection();

            collection.AddSingleton(loggerFactory);
            collection.AddSingleton(typeof(ILogger <>), typeof(Logger <>));

            var builder = new ContainerBuilder();

            builder.Populate(collection);

            builder.RegisterValidatorConfiguration(validatorConfig);
            builder.RegisterEndpointConfiguration(endpointConfig);
            builder.RegisterMessageHandlerFactory(messageHandlerFactory);
            builder.RegisterEndpoints(endpointConfig);
            builder.RegisterSourceRepositories(galleryUrl, indexUrl, galleryDatabase);
            builder.RegisterValidators(endpointConfig);

            builder
            .RegisterInstance(auditingStorageFactory)
            .AsSelf()
            .As <StorageFactory>();

            builder.RegisterType <PackageValidator>();

            var container = builder.Build();

            return(container.Resolve <PackageValidator>());
        }
예제 #2
0
        private DurableCursor CreateCursor(CatalogStorageFactory storageFactory, string filename)
        {
            var storage = storageFactory.Create();

            return(new DurableCursor(storage.ResolveUri(filename), storage, MemoryCursor.MinValue));
        }