InMemoryHistoryProvider
In-memory history provider. Optionally accepts seed entries so applications can pre-populate the history with example commands.
- Kind:
Class - Namespace: Repl
- Assembly:
Repl.Core - Source: src/Repl.Core/Console/InMemoryHistoryProvider.cs
Signature
Section titled “Signature”public sealed class InMemoryHistoryProvider : IHistoryProviderInheritance
Section titled “Inheritance”Implements
Section titled “Implements”Constructors
Section titled “Constructors”InMemoryHistoryProvider()
Section titled “InMemoryHistoryProvider()”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)Parameters
Section titled “Parameters”seedEntries(IEnumerable<string>): Initial history entries.
Methods
Section titled “Methods”AddAsync(string, CancellationToken)
Section titled “AddAsync(string, CancellationToken)”Persists one interactive command line.
public ValueTask AddAsync(string entry, CancellationToken cancellationToken = default)Parameters
Section titled “Parameters”entry(string): Raw command line as typed by the user.cancellationToken(CancellationToken): Cancellation token.
Returns
Section titled “Returns”ValueTask - An awaitable operation.
GetRecentAsync(int, CancellationToken)
Section titled “GetRecentAsync(int, CancellationToken)”Reads the most recent history entries.
public ValueTask<IReadOnlyList<string>> GetRecentAsync(int maxCount, CancellationToken cancellationToken = default)Parameters
Section titled “Parameters”maxCount(int): Maximum number of entries to return.cancellationToken(CancellationToken): Cancellation token.
Returns
Section titled “Returns”ValueTask<IReadOnlyList<string>> - Most recent entries ordered from oldest to newest within the returned window.