Table of Contents

Interface IAsset

Namespace
VpnHood.Net.Toolkit.Assets
Assembly
VpnHood.Net.Toolkit.dll

Represents one thing to open: a provider with its path already chosen. It names the asset, so a failure can name it, where a bare delegate could only say that something failed.

public interface IAsset

Remarks

Take this in a signature, and make an Asset, or a FileAsset for a path: where the bytes come from is the caller's business. It keeps the contract of OpenReadAsync(string, CancellationToken): a new stream every call, which the caller owns and disposes, read forward, and AssetNotFoundException when there is none. A caller that only asks takes TryOpenReadAsync.

Methods

OpenReadAsync(CancellationToken)

Opens the asset.

Task<Stream> OpenReadAsync(CancellationToken cancellationToken)

Parameters

cancellationToken CancellationToken

The token to monitor for cancellation requests.

Returns

Task<Stream>

A task whose result is a new stream, which the caller owns and disposes; read it forward.

Exceptions

AssetNotFoundException

There is no such asset.