Class InheritedTypeGridView<T1, T2>
Grid view that translates from T1 to T2, assuming T2 inherits from T1, by simply casting.
Inherited Members
Namespace: GoRogue.GridViews
Assembly: GoRogue.dll
Syntax
public class InheritedTypeGridView<T1, T2> : SettableTranslationGridView<T1, T2>, ISettableGridView<T2>, IGridView<T2> where T1 : T2
Type Parameters
Name | Description |
---|---|
T1 | Base type of grid view to implement. |
T2 | Value inheriting from/implementing T1. |
Remarks
This is useful to implement full co-variance/contra-variance with grid views, if you know that values that will be put into the grid will be of a particular type. An exception will occur if casting a value to T2 fails.
Constructors
View SourceInheritedTypeGridView(ISettableGridView<T1>)
Constructor. Takes an existing grid view to create a view from.
Declaration
public InheritedTypeGridView(ISettableGridView<T1> baseGrid)
Parameters
Type | Name | Description |
---|---|---|
ISettableGridView<T1> | baseGrid | A grid view exposing your underlying map data. |
InheritedTypeGridView(ISettableGridView<T1>, ISettableGridView<T2>)
Constructor. Takes an existing grid view to create a view from and applies view data to it.
Declaration
public InheritedTypeGridView(ISettableGridView<T1> baseGrid, ISettableGridView<T2> overlay)
Parameters
Type | Name | Description |
---|---|---|
ISettableGridView<T1> | baseGrid | Your underlying map data. |
ISettableGridView<T2> | overlay | The view data to apply to the grid. Must have identical dimensions to |
Remarks
Since this constructor must call TranslateSet to perform its function, do NOT call this constructor if the TranslateSet implementation depends on the derived class's constructor being completed to function properly.
Methods
View SourceTranslateGet(T1)
Translates your underlying data into the view type. Takes only a value from the underlying data. If a position is also needed to perform the translation, use TranslateGet(Point, T1) instead.
Declaration
protected override T2 TranslateGet(T1 value)
Parameters
Type | Name | Description |
---|---|---|
T1 | value | The data value from your underlying data. |
Returns
Type | Description |
---|---|
T2 | A value of the mapped data type. |
Overrides
TranslateSet(T2)
Translates the view type into the appropriate form for your underlying data. Takes only a value from the grid view itself. If a position is also needed to perform the translation, use TranslateSet(Point, T2) instead.
Declaration
protected override T1 TranslateSet(T2 value)
Parameters
Type | Name | Description |
---|---|---|
T2 | value | A value of the mapped data type. |
Returns
Type | Description |
---|---|
T1 | The data value for your underlying representation. |