Table of Contents

Interface IAssetLoader

Namespace
Avalonia.Platform
Assembly
Avalonia.Base.dll

Loads assets compiled into the application binary.

[Unstable("IAssetLoader interface and AvaloniaLocator usage is considered unstable. Please use AssetLoader static class instead.")]
public interface IAssetLoader

Methods

Exists(Uri, Uri?)

Checks if an asset with the specified URI exists.

bool Exists(Uri uri, Uri? baseUri = null)

Parameters

uri Uri

The URI.

baseUri Uri

A base URI to use if uri is relative.

Returns

bool

True if the asset could be found; otherwise false.

GetAssembly(Uri, Uri?)

Extracts assembly information from URI

Assembly? GetAssembly(Uri uri, Uri? baseUri = null)

Parameters

uri Uri

The URI.

baseUri Uri

A base URI to use if uri is relative.

Returns

Assembly

Assembly associated with the Uri

GetAssets(Uri, Uri?)

Gets all assets of a folder and subfolders that match specified uri.

IEnumerable<Uri> GetAssets(Uri uri, Uri? baseUri)

Parameters

uri Uri

The URI.

baseUri Uri

The base URI.

Returns

IEnumerable<Uri>

All matching assets as a tuple of the absolute path to the asset and the assembly containing the asset

InvalidateAssemblyCache()

Removes all assemblies from the cache.

void InvalidateAssemblyCache()

InvalidateAssemblyCache(string)

Removes the assembly from the cache.

void InvalidateAssemblyCache(string name)

Parameters

name string

The Assemblies.First().GetName().Name

Open(Uri, Uri?)

Opens the asset with the requested URI.

Stream Open(Uri uri, Uri? baseUri = null)

Parameters

uri Uri

The URI.

baseUri Uri

A base URI to use if uri is relative.

Returns

Stream

A stream containing the asset contents.

Exceptions

FileNotFoundException

The asset could not be found.

OpenAndGetAssembly(Uri, Uri?)

Opens the asset with the requested URI and returns the asset stream and the assembly containing the asset.

(Stream stream, Assembly assembly) OpenAndGetAssembly(Uri uri, Uri? baseUri = null)

Parameters

uri Uri

The URI.

baseUri Uri

A base URI to use if uri is relative.

Returns

(Stream stream, Assembly assembly)

The stream containing the asset contents together with the assembly.

Exceptions

FileNotFoundException

The asset could not be found.

SetDefaultAssembly(Assembly)

We need a way to override the default assembly selected by the host platform because right now it is selecting the wrong one for PCL based Apps. The AssetLoader needs a refactor cause right now it lives in 3+ platforms which can all be loaded on Windows.

void SetDefaultAssembly(Assembly assembly)

Parameters

assembly Assembly