Skip to content

InMemoryHistoryProvider

In-memory history provider. Optionally accepts seed entries so applications can pre-populate the history with example commands.

public sealed class InMemoryHistoryProvider : IHistoryProvider

Creates an empty history provider.

public InMemoryHistoryProvider()

InMemoryHistoryProvider(IEnumerable<string>)

Section titled “InMemoryHistoryProvider(IEnumerable<string>)”

Creates a history provider pre-populated with seed entries (oldest first).

public InMemoryHistoryProvider(IEnumerable<string> seedEntries)
  • seedEntries (IEnumerable<string>): Initial history entries.

Persists one interactive command line.

public ValueTask AddAsync(string entry, CancellationToken cancellationToken = default)
  • entry (string): Raw command line as typed by the user.
  • cancellationToken (CancellationToken): Cancellation token.

ValueTask - An awaitable operation.

Reads the most recent history entries.

public ValueTask<IReadOnlyList<string>> GetRecentAsync(int maxCount, CancellationToken cancellationToken = default)
  • maxCount (int): Maximum number of entries to return.
  • cancellationToken (CancellationToken): Cancellation token.

ValueTask<IReadOnlyList<string>> - Most recent entries ordered from oldest to newest within the returned window.