Skip to content
ConsoleMonster
Class

NavigationHistory<T>

ConsoleMonster.Interactive

Namespace
ConsoleMonster.Interactive
Assembly
ConsoleMonster
Modifiers
sealed

Back and forward through places a reader went, as a browser keeps them: NavigationHistory<T>.Visit before leaving for a new place, NavigationHistory<T>.TryBack and NavigationHistory<T>.TryForward to return. A place is whatever the caller needs to restore: a screen and scroll position, a document and section, a selected row.

Inheritance

  • object
  • NavigationHistory<T>

Type Parameters

T
A place.

Constructors

public NavigationHistory<T>(int capacity = 100) #

Creates an empty history.

Parameters

capacity int = 100 optional
The most places kept going back; the oldest are dropped first.

Methods

public void Clear() #

Forgets every place.

public bool TryBack(T? current, out T? place) #

Goes back, remembering the current place for going forward.

Parameters

current T? required
Where the reader is now.
place T? required
The place to return to.

Returns

bool Whether there was a place to go back to.
public bool TryForward(T? current, out T? place) #

Goes forward again, remembering the current place for going back.

Parameters

current T? required
Where the reader is now.
place T? required
The place to return to.

Returns

bool Whether there was a place to go forward to.
public void Visit(T? leaving) #

Records the place being left for a new one; going forward is no longer possible.

Parameters

leaving T? required
Where the reader is now.

Properties

public int Capacity { get; } #

The most places kept going back.

public bool CanGoBack { get; } #

Whether there is a place to go back to.

public bool CanGoForward { get; } #

Whether there is a place to go forward to.