Table of Contents

Class AssetManager

Namespace
Axolotl2D.Assets
Assembly
Axolotl2D.dll

Loads and caches typed assets through DI-provided loaders.

public sealed class AssetManager : IDisposable
Inheritance
AssetManager
Implements
Inherited Members

Constructors

AssetManager(IServiceProvider)

Loads and caches typed assets through DI-provided loaders.

public AssetManager(IServiceProvider services)

Parameters

services IServiceProvider

Methods

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

public void Dispose()

GetLoadedAssets()

Returns a point-in-time view of cached and in-progress assets.

public IReadOnlyList<AssetInfo> GetLoadedAssets()

Returns

IReadOnlyList<AssetInfo>

Get<TAsset>(string)

Returns a previously loaded asset.

public TAsset Get<TAsset>(string key) where TAsset : class

Parameters

key string

Returns

TAsset

Type Parameters

TAsset

LoadAsync<TAsset>(string, Stream, CancellationToken)

Loads an asset once and caches it under a type-safe key.

public ValueTask<TAsset> LoadAsync<TAsset>(string key, Stream stream, CancellationToken cancellationToken = default) where TAsset : class

Parameters

key string
stream Stream
cancellationToken CancellationToken

Returns

ValueTask<TAsset>

Type Parameters

TAsset

LoadEmbeddedAsync<TAsset>(string, Assembly, string, CancellationToken)

Loads an embedded resource and caches it.

public ValueTask<TAsset> LoadEmbeddedAsync<TAsset>(string key, Assembly assembly, string resourceName, CancellationToken cancellationToken = default) where TAsset : class

Parameters

key string
assembly Assembly
resourceName string
cancellationToken CancellationToken

Returns

ValueTask<TAsset>

Type Parameters

TAsset

LoadFileAsync<TAsset>(string, string, CancellationToken)

Loads an asset from a file and caches it.

public ValueTask<TAsset> LoadFileAsync<TAsset>(string key, string path, CancellationToken cancellationToken = default) where TAsset : class

Parameters

key string
path string
cancellationToken CancellationToken

Returns

ValueTask<TAsset>

Type Parameters

TAsset

TryGet<TAsset>(string, out TAsset?)

Attempts to return a loaded asset without blocking for in-progress loads.

public bool TryGet<TAsset>(string key, out TAsset? asset) where TAsset : class

Parameters

key string
asset TAsset

Returns

bool

Type Parameters

TAsset

Unload<TAsset>(string)

Removes and disposes an asset when it has finished loading.

public bool Unload<TAsset>(string key) where TAsset : class

Parameters

key string

Returns

bool

Type Parameters

TAsset