예제 #1
0
        private void SharedInit(bool useLegacy, bool useSemVer2, Uri baseUri = null, Uri indexUri = null, Uri contentBaseUri = null, Uri galleryBaseUri = null)
        {
            if (useLegacy)
            {
                _legacyStorage        = new MemoryStorage(baseUri ?? new Uri("http://tempuri.org"));
                _legacyStorageFactory = new TestStorageFactory(name => _legacyStorage.WithName(name));
            }

            if (useSemVer2)
            {
                _semVer2Storage        = new MemoryStorage(baseUri ?? new Uri("http://tempuri.org"));
                _semVer2StorageFactory = new TestStorageFactory(name => _semVer2Storage.WithName(name));
            }

            _mockServer = new MockServerHttpClientHandler();
            _mockServer.SetAction("/", request => Task.FromResult(new HttpResponseMessage(HttpStatusCode.OK)));

            _target = new RegistrationCollector(
                indexUri ?? new Uri("http://tempuri.org/index.json"),
                _legacyStorageFactory,
                _semVer2StorageFactory,
                contentBaseUri ?? new Uri("http://tempuri.org/packages"),
                galleryBaseUri ?? new Uri("http://tempuri.org/gallery"),
                Mock.Of <ITelemetryService>(),
                Mock.Of <ILogger>(),
                handlerFunc: () => _mockServer,
                httpRetryStrategy: new NoRetryStrategy());

            RegistrationMakerCatalogItem.PackagePathProvider = new PackagesFolderPackagePathProvider();
        }
예제 #2
0
        protected override void Init(IDictionary <string, string> arguments, CancellationToken cancellationToken)
        {
            PrintLightning();

            // Hard code against Azure storage.
            arguments[Arguments.StorageType] = Arguments.AzureStorageType;

            // Configure the package path provider.
            var useFlatContainerAsPackageContent = arguments.GetOrDefault <bool>(Arguments.ContentIsFlatContainer, false);

            if (!useFlatContainerAsPackageContent)
            {
                RegistrationMakerCatalogItem.PackagePathProvider = new PackagesFolderPackagePathProvider();
            }
            else
            {
                var flatContainerName = arguments.GetOrThrow <string>(Arguments.FlatContainerName);
                RegistrationMakerCatalogItem.PackagePathProvider = new FlatContainerPackagePathProvider(flatContainerName);
            }

            _command            = arguments.GetOrThrow <string>(Arguments.Command);
            _verbose            = arguments.GetOrDefault(Arguments.Verbose, false);
            _log                = _verbose ? Console.Out : new StringWriter();
            _contentBaseAddress = arguments.GetOrThrow <string>(Arguments.ContentBaseAddress);
            _galleryBaseAddress = arguments.GetOrThrow <string>(Arguments.GalleryBaseAddress);
            _storageFactories   = CommandHelpers.CreateRegistrationStorageFactories(arguments, _verbose);
            _shouldIncludeSemVer2ForLegacyStorageFactory = RegistrationCollector.GetShouldIncludeRegistrationPackageForLegacyStorageFactory(_storageFactories.SemVer2StorageFactory);
            _postProcessGraphForLegacyStorageFactory     = RegistrationCollector.GetPostProcessGraphForLegacyStorageFactory(_storageFactories.SemVer2StorageFactory);
            _forceIconsFromFlatContainer = arguments.GetOrDefault <bool>(Arguments.AllIconsInFlatContainer);
            _driver = arguments.GetOrDefault(Arguments.Driver, GraphDriver).ToLowerInvariant();
            // We save the arguments because the "prepare" command generates "strike" commands. Some of the arguments
            // used by "prepare" should be used when executing "strike".
            _arguments = arguments;

            if (_driver != GraphDriver && _driver != JsonDriver)
            {
                throw new NotSupportedException($"The lightning driver '{_driver}' is not supported.");
            }

            switch (_command.ToLowerInvariant())
            {
            case "charge":
            case "prepare":
                InitPrepare(arguments);
                break;

            case "strike":
                InitStrike(arguments);
                break;

            default:
                throw new NotSupportedException($"The lightning command '{_command}' is not supported.");
            }
        }
예제 #3
0
        async Task CreateRegistrationBlobs(Uri catalogIndex, Func <StorageHttpMessageHandler> handlerFunc, CancellationToken cancellationToken)
        {
            var factory = new MemoryStorageFactory(new Uri(_baseAddress, Registration), _store);

            CommitCollector collector = new RegistrationCollector(catalogIndex, factory, handlerFunc)
            {
                ContentBaseAddress = new Uri("http://tempuri.org/content/"),
                UnlistShouldDelete = false
            };

            await collector.Run(
                new MemoryCursor(DateTime.MinValue.ToUniversalTime()),
                new MemoryCursor(DateTime.MaxValue.ToUniversalTime()),
                cancellationToken);
        }
예제 #4
0
        private async Task ExecuteCatalog2RegistrationAsync(PerBatchContext context, Uri catalogIndexUri)
        {
            var serviceProvider = GetServiceProvider(
                context,
                context.Global.RegistrationContainerName,
                storagePath: null);

            var registrationStorageFactories = serviceProvider.GetRequiredService <RegistrationStorageFactories>();

            var collector = new RegistrationCollector(
                catalogIndexUri,
                registrationStorageFactories.LegacyStorageFactory,
                registrationStorageFactories.SemVer2StorageFactory,
                context.Global.ContentBaseAddress,
                serviceProvider.GetRequiredService <ITelemetryService>(),
                () => serviceProvider.GetRequiredService <HttpMessageHandler>());

            await collector.RunAsync(CancellationToken.None);
        }
예제 #5
0
        public static async Task Test4Async()
        {
            Uri catalogUri = new Uri("https://nugetdevstorage.blob.core.windows.net/catalog/index.json");

            string path = "c:\\data\\registration20150417";

            DirectoryInfo directoryInfo = new DirectoryInfo(path);

            if (directoryInfo.Exists)
            {
                directoryInfo.Delete(true);
            }
            directoryInfo.Create();

            FileStorageFactory factory = new FileStorageFactory(new Uri("http://tempuri.org"), path);

            CollectorBase collector = new RegistrationCollector(catalogUri, factory);

            await collector.Run();
        }