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
-
objectUrlReferenceContentManagerExtenstions
Methods
Exists(IContentManager, IUrlReference)
Check if the specified asset url exists.
public static bool Exists(this IContentManager content, IUrlReference urlReference)
Parameters
contentIContentManagerThe IContentManager.
urlReferenceIUrlReferenceThe URL.
Returns
- bool
trueif the specified asset url exists,falseotherwise.
Exceptions
- ArgumentNullException
If
urlReferenceisnullorempty. Orcontentisnull.
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
contentIContentManagerurlReferenceUrlReference<T>The URL of the asset to retrieve.
Returns
- T
The loaded asset, or
nullif the asset has not been loaded.
Type Parameters
TThe type of asset to retrieve.
Remarks
This function does not increase the reference count on the asset.
Exceptions
- ArgumentNullException
If
urlReferenceisnullorempty. Orcontentisnull.
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
contentIContentManagerurlReferenceIUrlReferenceThe URL to check.
loadedManuallyOnlyboolIf
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
Trueif an asset with the given URL is currently loaded,falseotherwise.
Exceptions
- ArgumentNullException
If
urlReferenceisnullorempty. Orcontentisnull.
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
contentIContentManagerThe IContentManager.
urlReferenceUrlReference<T>The URL to load from.
settingsContentManagerLoaderSettingsThe settings. If null, fallback to Default.
Returns
- Task<T>
The loaded content.
Type Parameters
TThe content type.
Exceptions
- ArgumentNullException
If
urlReferenceisnullorempty. Orcontentisnull.
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
contentIContentManagerThe IContentManager.
urlReferenceUrlReference<T>The URL to load from.
settingsContentManagerLoaderSettingsThe settings. If null, fallback to Default.
Returns
- T
The loaded content.
Type Parameters
TThe content type.
Exceptions
- ArgumentNullException
If
urlReferenceisnullorempty. Orcontentisnull.
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
contentIContentManagerThe IContentManager.
urlReferenceUrlReferenceThe URL to the raw asset.
streamFlagsStreamFlagsThe type of stream needed
Returns
- Stream
A stream to the raw asset.
Exceptions
- ArgumentNullException
If
urlReferenceisnullorempty. Orcontentisnull.
Unload(IContentManager, IUrlReference)
Unloads the asset at the specified URL.
public static void Unload(this IContentManager content, IUrlReference urlReference)
Parameters
contentIContentManagerurlReferenceIUrlReferenceThe URL.
Exceptions
- ArgumentNullException
If
urlReferenceisnullorempty. Orcontentisnull.