Table of Contents

Class AssetLoader

Namespace
Avalonia.Platform
Assembly
Avalonia.Base.dll

Loads assets compiled into the application binary.

public static class AssetLoader
Inheritance
AssetLoader
Inherited Members

Methods

Exists(Uri, Uri?)

Checks if an asset with the specified URI exists.

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

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

public static 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 the assembly from the cache.

public static void InvalidateAssemblyCache()

InvalidateAssemblyCache(string)

Removes all assemblies from the cache.

public static void InvalidateAssemblyCache(string name)

Parameters

name string

Open(Uri, Uri?)

Opens the asset with the requested URI.

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

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

public static void SetDefaultAssembly(Assembly assembly)

Parameters

assembly Assembly