Interface IEntityLoaderService
Defines an IService that allows for loading of any IEntity.
The IEntityLoaderService makes the assumption that the IStaticData associated with the Entity being loaded has been stored inside the IDataLoaderService.
Namespace: IdleKit.Framework
Assembly: cs.temp.dll.dll
Syntax
public interface IEntityLoaderService : IService, IInjectable
Methods
LoadAllEntities<TReturn, TData>()
Loads all IEntity of a given type that have an associated IEntityData held in the IContainer. If the IEntity does not exist in the IContainer, one will be created and cached in the IContainer.
Declaration
TReturn[] LoadAllEntities<TReturn, TData>()
where TReturn : class, IEntity where TData : class, IEntityData
Returns
Type | Description |
---|---|
TReturn[] | The loaded IEntity. |
Type Parameters
Name | Description |
---|---|
TReturn | |
TData |
Remarks
This method of loading does not allow for multiple instances of the same Entity Controller to be created. If this is required the LoadEntity<TReturn, TData>(String, String) method should be used.
LoadEntities<TReturn, TData>(String[])
Loads all IEntity based on the requested data Ids specified in dataIds
.
If the IEntity is not found in the IContainer, one will be created and stored
in IContainer.
Declaration
TReturn[] LoadEntities<TReturn, TData>(string[] dataIds)
where TReturn : class, IEntity where TData : class, IEntityData
Parameters
Type | Name | Description |
---|---|---|
String[] | dataIds |
Returns
Type | Description |
---|---|
TReturn[] | The loaded IEntity. |
Type Parameters
Name | Description |
---|---|
TReturn | |
TData |
Remarks
The Ids specified via dataIds
must all be for the same IEntity type.
This method of loading does not allow for multiple instances of the same IEntity to be
created. If this is required the LoadEntity<TReturn, TData>(String, String) method should be used.
LoadEntity<TReturn, TData>(String, String)
Loads the IEntity providing the dataId
.
If no cached IEntity is found in the IContainer, then one will be created via
the IEntityData associated with he dataId
and stored in the
IContainer.
The instanceId created will be the same as the instanceId
;
therefore making the returned IEntity unique.
Declaration
TReturn LoadEntity<TReturn, TData>(string dataId, string instanceId = null)
where TReturn : class, IEntity where TData : class, IEntityData
Parameters
Type | Name | Description |
---|---|---|
String | dataId | |
String | instanceId |
Returns
Type | Description |
---|---|
TReturn | The loaded IEntity. |
Type Parameters
Name | Description |
---|---|
TReturn | |
TData |
UnloadEntities<TEntity>(TEntity[])
The batch version of the UnloadEntity<TEntity>(TEntity).
Declaration
void UnloadEntities<TEntity>(TEntity[] entities)
where TEntity : class, IEntity
Parameters
Type | Name | Description |
---|---|---|
TEntity[] | entities |
Type Parameters
Name | Description |
---|---|
TEntity |
UnloadEntity<TEntity>(TEntity)
All IEntity loaded by LoadEntity<TReturn, TData>(String, String) must be unloaded by the UnloadEntity<TEntity>(TEntity) from the cache IContainer when the IEntity is no longer requires (i.e: moving to a new IContent or IStage.
It should unload the IEntity from the IContainer and call
Cleanup(IEntityLoaderService) on the IEntity to cleanup IEntity own by the
entity
.
Declaration
void UnloadEntity<TEntity>(TEntity entity)
where TEntity : class, IEntity
Parameters
Type | Name | Description |
---|---|---|
TEntity | entity |
Type Parameters
Name | Description |
---|---|
TEntity |