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
IContentManagerThe IContentManager.
urlReference
IUrlReferenceThe URL.
Returns
- bool
true
if the specified asset url exists,false
otherwise.
Exceptions
- ArgumentNullException
If
urlReference
isnull
orempty
. Orcontent
isnull
.
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
IContentManagerurlReference
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
isnull
orempty
. Orcontent
isnull
.
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
IContentManagerurlReference
IUrlReferenceThe URL to check.
loadedManuallyOnly
boolIf
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
isnull
orempty
. Orcontent
isnull
.
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
IContentManagerThe IContentManager.
urlReference
UrlReference<T>The URL to load from.
settings
ContentManagerLoaderSettingsThe settings. If null, fallback to Default.
Returns
- Task<T>
The loaded content.
Type Parameters
T
The content type.
Exceptions
- ArgumentNullException
If
urlReference
isnull
orempty
. Orcontent
isnull
.
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
IContentManagerThe IContentManager.
urlReference
UrlReference<T>The URL to load from.
settings
ContentManagerLoaderSettingsThe settings. If null, fallback to Default.
Returns
- T
The loaded content.
Type Parameters
T
The content type.
Exceptions
- ArgumentNullException
If
urlReference
isnull
orempty
. Orcontent
isnull
.
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
IContentManagerThe IContentManager.
urlReference
UrlReferenceThe URL to the raw asset.
streamFlags
StreamFlagsThe type of stream needed
Returns
- Stream
A stream to the raw asset.
Exceptions
- ArgumentNullException
If
urlReference
isnull
orempty
. Orcontent
isnull
.
Unload(IContentManager, IUrlReference)
Unloads the asset at the specified URL.
public static void Unload(this IContentManager content, IUrlReference urlReference)
Parameters
content
IContentManagerurlReference
IUrlReferenceThe URL.
Exceptions
- ArgumentNullException
If
urlReference
isnull
orempty
. Orcontent
isnull
.