Ejemplo n.º 1
0
        public override async Task <DownloadResourceResult> GetDownloadResourceResultAsync(
            PackageIdentity identity,
            ISettings settings,
            ILogger logger,
            CancellationToken token)
        {
            if (identity == null)
            {
                throw new ArgumentNullException(nameof(identity));
            }

            if (settings == null)
            {
                throw new ArgumentNullException(nameof(settings));
            }

            if (logger == null)
            {
                throw new ArgumentNullException(nameof(logger));
            }

            var uri = await GetDownloadUrl(identity, logger, token);

            if (uri != null)
            {
                return(await GetDownloadResultUtility.GetDownloadResultAsync(_client, identity, uri, settings, logger, token));
            }

            return(new DownloadResourceResult(DownloadResourceResultStatus.NotFound));
        }
Ejemplo n.º 2
0
 public async Task <DownloadResourceResult> DownloadFromUrl(PackageIdentity package,
                                                            Uri downloadUri,
                                                            ISettings settings,
                                                            ILogger log,
                                                            CancellationToken token)
 {
     return(await GetDownloadResultUtility.GetDownloadResultAsync(_httpSource, package, downloadUri, settings, log, token));
 }
        public override async Task <DownloadResourceResult> GetDownloadResourceResultAsync(
            PackageIdentity identity,
            PackageDownloadContext downloadContext,
            string globalPackagesFolder,
            ILogger logger,
            CancellationToken token)
        {
            if (identity == null)
            {
                throw new ArgumentNullException(nameof(identity));
            }

            if (downloadContext == null)
            {
                throw new ArgumentNullException(nameof(downloadContext));
            }

            if (logger == null)
            {
                throw new ArgumentNullException(nameof(logger));
            }

            var stopwatch = Stopwatch.StartNew();

            try
            {
                var uri = await GetDownloadUrl(identity, logger, token);

                if (uri != null)
                {
                    return(await GetDownloadResultUtility.GetDownloadResultAsync(
                               _client,
                               identity,
                               uri,
                               downloadContext,
                               globalPackagesFolder,
                               logger,
                               token));
                }

                return(new DownloadResourceResult(DownloadResourceResultStatus.NotFound));
            }
            finally
            {
                ProtocolDiagnostics.RaiseEvent(new ProtocolDiagnosticResourceEvent(
                                                   _source,
                                                   resourceType: nameof(DownloadResource),
                                                   type: nameof(DownloadResourceV3),
                                                   method: nameof(GetDownloadResourceResultAsync),
                                                   duration: stopwatch.Elapsed));
            }
        }
Ejemplo n.º 4
0
        public async Task <DownloadResourceResult> DownloadFromIdentity(PackageIdentity package,
                                                                        ISettings settings,
                                                                        ILogger log,
                                                                        CancellationToken token)
        {
            var packageInfo = await GetPackage(package, log, token);

            if (packageInfo == null)
            {
                return(new DownloadResourceResult(DownloadResourceResultStatus.NotFound));
            }

            return(await GetDownloadResultUtility.GetDownloadResultAsync(_httpSource, package, new Uri(packageInfo.DownloadUrl), settings, log, token));
        }
Ejemplo n.º 5
0
 public async Task <DownloadResourceResult> DownloadFromUrl(
     PackageIdentity package,
     Uri downloadUri,
     PackageDownloadContext downloadContext,
     string globalPackagesFolder,
     ILogger log,
     CancellationToken token)
 {
     return(await GetDownloadResultUtility.GetDownloadResultAsync(
                _httpSource,
                package,
                downloadUri,
                downloadContext,
                globalPackagesFolder,
                log,
                token));
 }
Ejemplo n.º 6
0
        public override async Task <DownloadResourceResult> GetDownloadResourceResultAsync(
            PackageIdentity identity,
            PackageDownloadContext downloadContext,
            string globalPackagesFolder,
            ILogger logger,
            CancellationToken token)
        {
            if (identity == null)
            {
                throw new ArgumentNullException(nameof(identity));
            }

            if (downloadContext == null)
            {
                throw new ArgumentNullException(nameof(downloadContext));
            }

            if (logger == null)
            {
                throw new ArgumentNullException(nameof(logger));
            }

            var uri = await GetDownloadUrl(identity, logger, token);

            if (uri != null)
            {
                return(await GetDownloadResultUtility.GetDownloadResultAsync(
                           _client,
                           identity,
                           uri,
                           downloadContext,
                           globalPackagesFolder,
                           logger,
                           token));
            }

            return(new DownloadResourceResult(DownloadResourceResultStatus.NotFound));
        }
Ejemplo n.º 7
0
        public async Task <DownloadResourceResult> DownloadFromIdentity(
            PackageIdentity package,
            PackageDownloadContext downloadContext,
            string globalPackagesFolder,
            ILogger log,
            CancellationToken token)
        {
            var packageInfo = await GetPackage(package, log, token);

            if (packageInfo == null)
            {
                return(new DownloadResourceResult(DownloadResourceResultStatus.NotFound));
            }

            return(await GetDownloadResultUtility.GetDownloadResultAsync(
                       _httpSource,
                       package,
                       new Uri(packageInfo.DownloadUrl),
                       downloadContext,
                       globalPackagesFolder,
                       log,
                       token));
        }