Class LambdaTranslationGridView<T1, T2>
A simple TranslationGridView<T1, T2> implementation that allows you to provide a function/lambda at construction to use as the TranslateGet(Point, T1) implementation. For a version offering "set" functionality, see LambdaSettableTranslationGridView<T1, T2>.
Implements
Inherited Members
Namespace: SadRogue.Primitives.GridViews
Assembly: TheSadRogue.Primitives.dll
Syntax
public sealed class LambdaTranslationGridView<T1, T2> : TranslationGridView<T1, T2>, IGridView<T2>
Type Parameters
| Name | Description |
|---|---|
| T1 | The type of your underlying data. |
| T2 | The type of the data being exposed by the grid view. |
Constructors
LambdaTranslationGridView(IGridView<T1>, Func<T1, T2>)
Constructor. Takes an existing grid view to create a view from and a getter function taking only a value of type T1.
Declaration
public LambdaTranslationGridView(IGridView<T1> baseGrid, Func<T1, T2> getter)
Parameters
| Type | Name | Description |
|---|---|---|
| IGridView<T1> | baseGrid | Your underlying grid data. |
| Func<T1, T2> | getter | The TranslateGet implementation. |
Remarks
If a position is also needed to perform the translation, an overload is provided taking a corresponding function.
LambdaTranslationGridView(IGridView<T1>, Func<Point, T1, T2>)
Constructor. Takes an existing grid view to create a view from and a getter function taking a value of type T1 and its corresponding position.
Declaration
public LambdaTranslationGridView(IGridView<T1> baseGrid, Func<Point, T1, T2> getter)
Parameters
| Type | Name | Description |
|---|---|---|
| IGridView<T1> | baseGrid | Your underlying grid data. |
| Func<Point, T1, T2> | getter | The TranslateGet implementation. |
Methods
TranslateGet(Point, T1)
Translates your underlying data into the view type by calling the getter function specified in the class constructor.
Declaration
protected override T2 TranslateGet(Point position, T1 value)
Parameters
| Type | Name | Description |
|---|---|---|
| Point | position | Position corresponding to given value from your underlying data. |
| T1 | value | The value from your underlying data. |
Returns
| Type | Description |
|---|---|
| T2 | A value of the mapped data type (via the getter specified in the class constructor). |