Interface IAssetSource
Provides read access to assets within a source (e.g. a file system directory or ZIP archive).
public interface IAssetSource : IDisposable, IAsyncDisposable
- Inherited Members
Methods
OpenAsync(string, CancellationToken)
Opens a readable stream for the asset at the given relative path within the source.
Task<Stream> OpenAsync(string relativePath, CancellationToken cancellationToken = default)
Parameters
relativePathstringA forward-slash separated relative path to the asset.
cancellationTokenCancellationTokenA cancellation token.
Returns
ReadAllBytesAsync(string, CancellationToken)
Reads the asset at relativePath fully into memory and
returns an AssetBytes view over its contents.
Task<AssetBytes> ReadAllBytesAsync(string relativePath, CancellationToken cancellationToken = default)
Parameters
relativePathstringA forward-slash separated relative path to the asset.
cancellationTokenCancellationTokenA cancellation token.
Returns
- Task<AssetBytes>
An AssetBytes containing the asset contents.
Remarks
The default implementation opens the asset via OpenAsync(string, CancellationToken)
and copies the stream into a fresh buffer, allocating one array per call
(with a fast path for exposable MemoryStream sources).
A source that already holds the bytes in memory — for example
CachingAssetSource — should override this to serve them directly
and avoid the stream round-trip, so the acceleration applies even when
the source is referenced through IAssetSource.