コード例 #1
0
 public PackageMetadataService(
     IServiceIndexService serviceIndexService,
     IRegistrationClient registrationClient,
     IPackageContentClient packageContentClient)
 {
     _serviceIndexService  = serviceIndexService ?? throw new ArgumentNullException(nameof(serviceIndexService));
     _registrationClient   = registrationClient ?? throw new ArgumentNullException(nameof(registrationClient));
     _packageContentClient = packageContentClient ?? throw new ArgumentNullException(nameof(packageContentClient));
 }
コード例 #2
0
ファイル: NuGetClient.cs プロジェクト: vjacquet/BaGet
        /// <summary>
        /// Initializes a new instance of the <see cref="NuGetClient"/> class.
        /// </summary>
        /// <param name="clientFactory">The factory used to create NuGet clients.</param>
        public NuGetClient(NuGetClientFactory clientFactory)
        {
            if (clientFactory == null)
            {
                throw new ArgumentNullException(nameof(clientFactory));
            }

            _contentClient  = clientFactory.CreatePackageContentClient();
            _metadataClient = clientFactory.CreatePackageMetadataClient();
            _searchClient   = clientFactory.CreateSearchClient();
        }
コード例 #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="NuGetClient"/> class.
        /// </summary>
        /// <param name="serviceIndexUrl">
        /// The NuGet Service Index resource URL.
        ///
        /// For NuGet.org, use https://api.nuget.org/v3/index.json
        /// </param>
        public NuGetClient(string serviceIndexUrl)
        {
            var httpClient = new HttpClient(new HttpClientHandler
            {
                AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate,
            });

            var clientFactory = new NuGetClientFactory(httpClient, serviceIndexUrl);

            _contentClient  = clientFactory.CreatePackageContentClient();
            _metadataClient = clientFactory.CreatePackageMetadataClient();
            _searchClient   = clientFactory.CreateSearchClient();
        }