コード例 #1
0
        /// <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();
            _autocompleteClient = clientFactory.CreateAutocompleteClient();
        }
コード例 #2
0
ファイル: NuGetClient.cs プロジェクト: Mik4sa/BaGet
        /// <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();
            _autocompleteClient = clientFactory.CreateAutocompleteClient();
        }