Table of Contents

Interface IPackageDownloader

Namespace
NuGet.Packaging
Assembly
Chocolatey.NuGet.Packaging.dll

A package downloader.

public interface IPackageDownloader : IDisposable
Inherited Members

Properties

ContentReader

Gets an asynchronous package content reader.

IAsyncPackageContentReader ContentReader { get; }

Property Value

IAsyncPackageContentReader

Exceptions

ObjectDisposedException

Thrown if this object is disposed.

CoreReader

Gets an asynchronous package core reader.

IAsyncPackageCoreReader CoreReader { get; }

Property Value

IAsyncPackageCoreReader

Exceptions

ObjectDisposedException

Thrown if this object is disposed.

SignedPackageReader

ISignedPackageReader SignedPackageReader { get; }

Property Value

ISignedPackageReader

Source

string Source { get; }

Property Value

string

Methods

CopyNupkgFileToAsync(string, CancellationToken)

Asynchronously copies a .nupkg to a target file path.

Task<bool> CopyNupkgFileToAsync(string destinationFilePath, CancellationToken cancellationToken)

Parameters

destinationFilePath string

The destination file path.

cancellationToken CancellationToken

A cancellation token.

Returns

Task<bool>

A task that represents the asynchronous operation. The task result (Result) returns a bool indicating whether or not the copy was successful.

Exceptions

ObjectDisposedException

Thrown if this object is disposed.

ArgumentException

Thrown if destinationFilePath is either null or empty.

OperationCanceledException

Thrown if cancellationToken is cancelled.

GetPackageHashAsync(string, CancellationToken)

Asynchronously gets a package hash.

Task<string> GetPackageHashAsync(string hashAlgorithm, CancellationToken cancellationToken)

Parameters

hashAlgorithm string

The hash algorithm.

cancellationToken CancellationToken

A cancellation token.

Returns

Task<string>

A task that represents the asynchronous operation. The task result (Result) returns a string representing the package hash.

Exceptions

ObjectDisposedException

Thrown if this object is disposed.

ArgumentException

Thrown if hashAlgorithm is either null or empty.

OperationCanceledException

Thrown if cancellationToken is cancelled.

SetExceptionHandler(Func<Exception, Task<bool>>)

Sets an exception handler for package downloads.

void SetExceptionHandler(Func<Exception, Task<bool>> handleExceptionAsync)

Parameters

handleExceptionAsync Func<Exception, Task<bool>>

An exception handler.

Remarks

The exception handler returns a task that represents the asynchronous operation. The task result (Result) returns a bool indicating whether or not the exception was handled. To handle an exception and stop its propagation, the task should return true. Otherwise, the exception will be rethrown.

Exceptions

ArgumentNullException

Thrown if handleExceptionAsync is null.

SetThrottle(SemaphoreSlim)

Sets a throttle for package downloads.

void SetThrottle(SemaphoreSlim throttle)

Parameters

throttle SemaphoreSlim

A throttle. Can be null.