Class ListChunkedDataLayer<TItem>
Base class for data layers that use Array{T} as a data storage and track changes per chunk.
Inheritance
Inherited Members
Namespace: Fwt.Core.DataLayers
Assembly: fwt.core.dll
Syntax
public abstract class ListChunkedDataLayer<TItem> : ChunkedDataLayer, IDisposable, ICommitChanges, IListDataLayer<TItem>
Type Parameters
| Name | Description |
|---|---|
| TItem | type of item stored in a data layer |
Fields
_data
Declaration
protected List<TItem> _data
Field Value
| Type | Description |
|---|---|
| List<TItem> |
Properties
Data
Container for layer data.
Declaration
public List<TItem> Data { get; }
Property Value
| Type | Description |
|---|---|
| List<TItem> |
Methods
Dispose()
Disposes the data layer, calls DisposeAllItems() DisposeAllItems()
Declaration
public override void Dispose()
Overrides
DisposeAllItems()
Disposes all items in the data layer by calling DisposeDataItem for each DisposeDataItem(TItem).
Declaration
public override void DisposeAllItems()
Overrides
DisposeDataItem(TItem)
Disposes data item if it is IDisposable.
Declaration
protected virtual void DisposeDataItem(TItem item)
Parameters
| Type | Name | Description |
|---|---|---|
| TItem | item |
DisposeExcessItems(int)
Disposes items at cells greater than layerSize
Declaration
public virtual void DisposeExcessItems(int layerSize)
Parameters
| Type | Name | Description |
|---|---|---|
| int | layerSize | items count to keep, dispose all other items |
GetData(int)
Returns data from cell at provided index
Declaration
public virtual TItem GetData(int index)
Parameters
| Type | Name | Description |
|---|---|---|
| int | index | cell index to get data from |
Returns
| Type | Description |
|---|---|
| TItem | data from cell at provided index |
GetDataOrDefault(int)
Tries to get data from cell at provided index.
Declaration
public virtual TItem GetDataOrDefault(int index)
Parameters
| Type | Name | Description |
|---|---|---|
| int | index | cell index to get data from |
Returns
| Type | Description |
|---|---|
| TItem | data found in cell at provided index or default if nothing was found |
Init(int)
Intializes/Reinitializes the data layer
Declaration
public override void Init(int layerSize)
Parameters
| Type | Name | Description |
|---|---|---|
| int | layerSize | amount of cells in the data layer |
Overrides
SetData(int, TItem)
Sets data in cell at provided index.
Declaration
public virtual bool SetData(int index, TItem data)
Parameters
| Type | Name | Description |
|---|---|---|
| int | index | cell index to put data into |
| TItem | data | data to put into the cell at provided index |
Returns
| Type | Description |
|---|---|
| bool | true if data was set |
TryGetData(int, out TItem)
Tries to get data from cell at provided index.
Declaration
public virtual bool TryGetData(int index, out TItem data)
Parameters
| Type | Name | Description |
|---|---|---|
| int | index | cell index to get data from |
| TItem | data | data found in a cell at provided index |
Returns
| Type | Description |
|---|---|
| bool | true if data was found |
TrySetData(int, TItem)
Tries to set data in cell at provided index.
Declaration
public virtual bool TrySetData(int index, TItem data)
Parameters
| Type | Name | Description |
|---|---|---|
| int | index | cell index to put data into |
| TItem | data | data to put into the cell at provided index |
Returns
| Type | Description |
|---|---|
| bool | true if data was set |