Show / Hide Table of Contents

Class AssetStorage

A class providing access to Assets. An asset is considered any content to be loaded, deserialized and converted during an application's lifetime. Often Assets should be loaded up-front and accessed during run-time with no perceivable delay. AssetStorage is a staticton (a singleton with an additional static interface).

Inheritance
System.Object
AssetStorage
Implements
System.IDisposable
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: Fusee.Base.Core
Assembly: Fusee.Base.Core.dll
Syntax
public sealed class AssetStorage : IDisposable
Remarks

The existence of this class is a tribute to the Web-world where a lot of asset types (e.g. images) are JavaScript built-in functionality with no possibility to separate the many aspects of asset-access (like loading, deserialization, codec, asynchronicity). Decent programming environments allow to separate these aspects using streams. A decoder is implemented against a stream. Anything capable of providing streams, synchronously or asynchronously thus can act as an asset store. If FUSEE had been designed without JavaScript X-compilation in mind, this class would probably not exist.

Properties

AllAssetsFinishedLoading

Returns true if all assets have finished loading, independent of failed or success state

Declaration
public static bool AllAssetsFinishedLoading { get; }
Property Value
Type Description
System.Boolean

Instance

Implements the Singleton pattern.

Declaration
public static AssetStorage Instance { get; }
Property Value
Type Description
AssetStorage

The (one-and-only) instance of AssetStorage.

Methods

DeepCopy<T>(T)

Creates a deep copy of the source object. Only works for source objects with the defined on their class.

Declaration
public static T DeepCopy<T>(T source)
    where T : class
Parameters
Type Name Description
T source

The source object to clone.

Returns
Type Description
T

A deep copy of the source object. All objects referenced directly and indirectly from the source object are copied, too.

Type Parameters
Name Description
T

Type of the source and object and the returned clone. Implicitly defined by the source parameter.

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

Declaration
public void Dispose()

Finalize()

Finalizers (historically referred to as destructors) are used to perform any necessary final clean-up when a class instance is being collected by the garbage collector.

Declaration
protected void Finalize()

Get<T>(String)

Staticton implementation of GetAsset<T>(String).

Declaration
public static T Get<T>(string id)
Parameters
Type Name Description
System.String id

The identifier.

Returns
Type Description
T
Type Parameters
Name Description
T

GetAsset<T>(String)

Retrieves the asset identified by id.

Declaration
public T GetAsset<T>(string id)
Parameters
Type Name Description
System.String id

The identifier.

Returns
Type Description
T

The asset, if found. Otherwise null.

Type Parameters
Name Description
T

The expected type of the asset to retrieve.

Remarks

Internally, this method queries all of the registered asset providers (RegisterAssetProvider(IAssetProvider). The first asset provider capable of retrieving the asset "wins". It's up to any application to guarantee uniqueness of asset identifiers among all assets and asset providers.

GetAssetAsync<T>(String)

Retrieves a System.Threading.Tasks.Task which loads the asset identified by id, eventually.

Declaration
public async Task<T> GetAssetAsync<T>(string id)
Parameters
Type Name Description
System.String id

The identifier.

Returns
Type Description
System.Threading.Tasks.Task<T>

The asset, if found. Otherwise null.

Type Parameters
Name Description
T

The expected type of the asset to retrieve.

Remarks

Internally, this method queries all of the registered asset providers (RegisterAssetProvider(IAssetProvider). The first asset provider capable of retrieving the asset "wins". It's up to any application to guarantee uniqueness of asset identifiers among all assets and asset providers.

GetAssetsAsync<T>(IEnumerable<String>)

Retrieves the assets identified by ids in an completely async parallel matter.

Declaration
public static Task<T[]> GetAssetsAsync<T>(IEnumerable<string> ids)
Parameters
Type Name Description
System.Collections.Generic.IEnumerable<System.String> ids

The identifiers.

Returns
Type Description
System.Threading.Tasks.Task<T[]>

The assets, if found. Otherwise null.

Type Parameters
Name Description
T

The expected types of the asset to retrieve.

GetAsync<T>(String)

Staticton implementation of GetAsset<T>(String).

Declaration
public static Task<T> GetAsync<T>(string id)
Parameters
Type Name Description
System.String id

The identifier.

Returns
Type Description
System.Threading.Tasks.Task<T>
Type Parameters
Name Description
T

IsAssetLoaded(String)

Returns true if an asset has finished loading successfully, returns false if not present, see IsAssetPresent(String)

Declaration
public static bool IsAssetLoaded(string id)
Parameters
Type Name Description
System.String id
Returns
Type Description
System.Boolean

IsAssetPresent(String)

Returns true if an asset is currently loading or already loaded, independent of failed or success state!

Declaration
public static bool IsAssetPresent(string id)
Parameters
Type Name Description
System.String id
Returns
Type Description
System.Boolean

RegisterAssetProvider(IAssetProvider)

Registers the given asset provider. Use this method to register asset providers for the platform (desktop, mobile, web) your main application should run on.

Declaration
public void RegisterAssetProvider(IAssetProvider assetProvider)
Parameters
Type Name Description
IAssetProvider assetProvider

The asset provider to register.

RegisterProvider(IAssetProvider)

Staticton implementation of RegisterAssetProvider(IAssetProvider).

Declaration
public static void RegisterProvider(IAssetProvider assetProvider)
Parameters
Type Name Description
IAssetProvider assetProvider

The asset provider.

UnRegisterAllAssetProviders()

Unregisters all asset providers.

Declaration
public static void UnRegisterAllAssetProviders()

Implements

System.IDisposable
Generated by DocFX
GitHub Repo
Back to top