Table of Contents

Class UrlReferenceContentManagerExtenstions

Namespace
Stride.Core.Serialization
Assembly
Stride.Core.Serialization.dll

Extension methods of IContentManager to allow usage of UrlReference and UrlReference<T>.

public static class UrlReferenceContentManagerExtenstions
Inheritance
UrlReferenceContentManagerExtenstions

Methods

Exists(IContentManager, IUrlReference)

Check if the specified asset url exists.

public static bool Exists(this IContentManager content, IUrlReference urlReference)

Parameters

content IContentManager

The IContentManager.

urlReference IUrlReference

The URL.

Returns

bool

true if the specified asset url exists, false otherwise.

Exceptions

ArgumentNullException

If urlReference is null or empty. Or content is null.

Get<T>(IContentManager, UrlReference<T>)

Gets a previously loaded asset from its URL.

public static T Get<T>(this IContentManager content, UrlReference<T> urlReference) where T : class

Parameters

content IContentManager
urlReference UrlReference<T>

The URL of the asset to retrieve.

Returns

T

The loaded asset, or null if the asset has not been loaded.

Type Parameters

T

The type of asset to retrieve.

Remarks

This function does not increase the reference count on the asset.

Exceptions

ArgumentNullException

If urlReference is null or empty. Or content is null.

IsLoaded(IContentManager, IUrlReference, bool)

Gets whether an asset with the given URL is currently loaded.

public static bool IsLoaded(this IContentManager content, IUrlReference urlReference, bool loadedManuallyOnly = false)

Parameters

content IContentManager
urlReference IUrlReference

The URL to check.

loadedManuallyOnly bool

If true, this method will return true only if an asset with the given URL has been manually loaded via Load<T>(IContentManager, UrlReference<T>, ContentManagerLoaderSettings), and not if the asset has been only loaded indirectly from another asset.

Returns

bool

True if an asset with the given URL is currently loaded, false otherwise.

Exceptions

ArgumentNullException

If urlReference is null or empty. Or content is null.

LoadAsync<T>(IContentManager, UrlReference<T>, ContentManagerLoaderSettings)

Loads content from the specified URL asynchronously.

public static Task<T> LoadAsync<T>(this IContentManager content, UrlReference<T> urlReference, ContentManagerLoaderSettings settings = null) where T : class

Parameters

content IContentManager

The IContentManager.

urlReference UrlReference<T>

The URL to load from.

settings ContentManagerLoaderSettings

The settings. If null, fallback to Default.

Returns

Task<T>

The loaded content.

Type Parameters

T

The content type.

Exceptions

ArgumentNullException

If urlReference is null or empty. Or content is null.

Load<T>(IContentManager, UrlReference<T>, ContentManagerLoaderSettings)

Loads content from the specified URL.

public static T Load<T>(this IContentManager content, UrlReference<T> urlReference, ContentManagerLoaderSettings settings = null) where T : class

Parameters

content IContentManager

The IContentManager.

urlReference UrlReference<T>

The URL to load from.

settings ContentManagerLoaderSettings

The settings. If null, fallback to Default.

Returns

T

The loaded content.

Type Parameters

T

The content type.

Exceptions

ArgumentNullException

If urlReference is null or empty. Or content is null.

OpenAsStream(IContentManager, UrlReference, StreamFlags)

Opens the specified URL as a stream used for custom raw asset loading.

public static Stream OpenAsStream(this IContentManager content, UrlReference urlReference, StreamFlags streamFlags = StreamFlags.None)

Parameters

content IContentManager

The IContentManager.

urlReference UrlReference

The URL to the raw asset.

streamFlags StreamFlags

The type of stream needed

Returns

Stream

A stream to the raw asset.

Exceptions

ArgumentNullException

If urlReference is null or empty. Or content is null.

Unload(IContentManager, IUrlReference)

Unloads the asset at the specified URL.

public static void Unload(this IContentManager content, IUrlReference urlReference)

Parameters

content IContentManager
urlReference IUrlReference

The URL.

Exceptions

ArgumentNullException

If urlReference is null or empty. Or content is null.