Table of Contents

Class StandardAssetLoader

Namespace
Avalonia.Platform
Assembly
Avalonia.Base.dll

Loads assets compiled into the application binary.

[Unstable("StandardAssetLoader is considered unstable. Please use AssetLoader static class instead.")]
public class StandardAssetLoader : IAssetLoader
Inheritance
StandardAssetLoader
Implements
Inherited Members

Constructors

StandardAssetLoader(Assembly?)

public StandardAssetLoader(Assembly? assembly = null)

Parameters

assembly Assembly

Methods

Exists(Uri, Uri?)

Checks if an asset with the specified URI exists.

public 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 Assembly? GetAssembly(Uri uri, Uri? baseUri)

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 IEnumerable<Uri> GetAssets(Uri uri, Uri? baseUri)

Parameters

uri Uri

The URI.

baseUri Uri

Base URI that is used if uri is relative.

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.

public void InvalidateAssemblyCache()

InvalidateAssemblyCache(string)

Removes the assembly from the cache.

public void InvalidateAssemblyCache(string name)

Parameters

name string

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

Open(Uri, Uri?)

Opens the asset with the requested URI.

public 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 (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 resource contents together with the assembly.

Exceptions

FileNotFoundException

The asset could not be found.

RegisterResUriParsers()

public static void RegisterResUriParsers()

SetDefaultAssembly(Assembly)

Sets the default assembly from which to load assets for which no assembly is specified.

public void SetDefaultAssembly(Assembly assembly)

Parameters

assembly Assembly

The default assembly.