Table of Contents

Class LocalPackageArchiveDownloader

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

A package downloader for local archive packages.

[Obsolete("Use NuGet.Protocol.LocalPackageArchiveDownloader")]
public sealed class LocalPackageArchiveDownloader : IPackageDownloader, IDisposable
Inheritance
LocalPackageArchiveDownloader
Implements
Inherited Members

Constructors

LocalPackageArchiveDownloader(string, string, PackageIdentity, ILogger)

Initializes a new LocalPackageArchiveDownloader class.

public LocalPackageArchiveDownloader(string source, string packageFilePath, PackageIdentity packageIdentity, ILogger logger)

Parameters

source string

A package source.

packageFilePath string

A source package archive file path.

packageIdentity PackageIdentity

A package identity.

logger ILogger

A logger.

Exceptions

ArgumentException

Thrown if packageFilePath is either null or an empty string.

ArgumentNullException

Thrown if packageIdentity is either null or an empty string.

ArgumentNullException

Thrown if logger is either null or an empty string.

Properties

ContentReader

Gets an asynchronous package content reader.

public IAsyncPackageContentReader ContentReader { get; }

Property Value

IAsyncPackageContentReader

Exceptions

ObjectDisposedException

Thrown if this object is disposed.

CoreReader

Gets an asynchronous package core reader.

public IAsyncPackageCoreReader CoreReader { get; }

Property Value

IAsyncPackageCoreReader

Exceptions

ObjectDisposedException

Thrown if this object is disposed.

SignedPackageReader

public ISignedPackageReader SignedPackageReader { get; }

Property Value

ISignedPackageReader

Source

public string Source { get; }

Property Value

string

Methods

CopyNupkgFileToAsync(string, CancellationToken)

Asynchronously copies a .nupkg to a target file path.

public 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.

Dispose()

Disposes of this instance.

public void Dispose()

GetPackageHashAsync(string, CancellationToken)

Asynchronously gets a package hash.

public 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.

public 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.

public void SetThrottle(SemaphoreSlim throttle)

Parameters

throttle SemaphoreSlim

A throttle. Can be null.