public override Task <Tuple <bool, INuGetResource> > TryCreate(SourceRepository source, CancellationToken token) { Debug.Assert(source.PackageSource.IsHttp, "HTTP source requested for a non-http source."); HttpSourceResource curResource = null; if (source.PackageSource.IsHttp) { IThrottle throttle = NullThrottle.Instance; if (Throttle != null) { throttle = Throttle; } else if (source.PackageSource.MaxHttpRequestsPerSource > 0) { throttle = SemaphoreSlimThrottle.CreateSemaphoreThrottle(source.PackageSource.MaxHttpRequestsPerSource); } curResource = _cache.GetOrAdd( source.PackageSource, packageSource => new HttpSourceResource(HttpSource.Create(source, throttle))); } return(Task.FromResult(new Tuple <bool, INuGetResource>(curResource != null, curResource))); }
public override Task <Tuple <bool, INuGetResource> > TryCreate(SourceRepository source, CancellationToken token) { Debug.Assert(source.PackageSource.IsHttp, "HTTP source requested for a non-http source."); HttpSourceResource curResource = null; if (source.PackageSource.IsHttp) { curResource = _cache.GetOrAdd(source.PackageSource, (packageSource) => new HttpSourceResource(HttpSource.Create(source))); } return(Task.FromResult(new Tuple <bool, INuGetResource>(curResource != null, curResource))); }
public PackageSearchResourceV2Feed(HttpSourceResource httpSourceResource, string baseAddress, Configuration.PackageSource packageSource) { if (httpSourceResource == null) { throw new ArgumentNullException(nameof(httpSourceResource)); } if (packageSource == null) { throw new ArgumentNullException(nameof(packageSource)); } _httpSource = httpSourceResource.HttpSource; _packageSource = packageSource; _feedParser = new V2FeedParser(_httpSource, baseAddress, packageSource); }
public AutoCompleteResourceV2Feed(HttpSourceResource httpSourceResource, string baseAddress, Configuration.PackageSource packageSource) { if (httpSourceResource == null) { throw new ArgumentNullException(nameof(httpSourceResource)); } if (packageSource == null) { throw new ArgumentNullException(nameof(packageSource)); } _httpSource = httpSourceResource.HttpSource; _baseUri = UriUtility.CreateSourceUri($"{baseAddress}/"); }