Class TerminalSystemConsole
The default implementation of ITerminalConsole that uses the system Console.
public class TerminalSystemConsole : ITerminalConsole
- Inheritance
-
TerminalSystemConsole
- Implements
- Inherited Members
Remarks
The TerminalSystemConsole is thread safe and allows multiple tasks to write to the console concurrently.
Constructors
TerminalSystemConsole()
Initializes a new instance of the TerminalSystemConsole class.
public TerminalSystemConsole()
Properties
BackgroundColor
Gets or sets the background color of the console.
public ConsoleColor BackgroundColor { get; set; }
Property Value
ForegroundColor
Gets or sets the foreground color of the console.
public ConsoleColor ForegroundColor { get; set; }
Property Value
Methods
ClearAsync()
Clears the console buffer and display information asynchronously.
public Task ClearAsync()
Returns
Ignore(string?)
Determines whether the specified string value should be ignored by the ITerminalConsole.
public bool Ignore(string? value)
Parameters
valuestringThe value to check.
Returns
- bool
trueif the value is null, empty, or whitespace; otherwise,false.
ReadAnswerAsync(string, params string[]?)
Prints a question to the console and waits for an answer asynchronously.
public Task<string> ReadAnswerAsync(string question, params string[]? answers)
Parameters
questionstringThe question to print. A
?will be appended at the end.answersstring[]The allowed answers, or
nullif all answers are allowed. If specified, this method prints the answers in the format{question} ({answer1}/{answer2}/{answer3})?.
Returns
ReadLineAsync()
Reads the next line of input from the console asynchronously.
public Task<string?> ReadLineAsync()
Returns
WriteAsync(string, params object[])
Writes a formatted string to the console asynchronously.
public Task WriteAsync(string value, params object[] args)
Parameters
Returns
WriteColorAsync(ConsoleColor, string, params object[])
Writes a formatted string to the console in the specified foreground color asynchronously.
public Task WriteColorAsync(ConsoleColor foregroundColor, string value, params object[] args)
Parameters
foregroundColorConsoleColorThe foreground color.
valuestringThe string to write.
argsobject[]The format arguments.
Returns
WriteLineAsync()
Writes a newline to the console asynchronously.
public Task WriteLineAsync()
Returns
WriteLineAsync(string, params object[])
Writes a formatted string followed by a newline to the console asynchronously.
public Task WriteLineAsync(string value, params object[] args)
Parameters
Returns
WriteLineColorAsync(ConsoleColor, string, params object[])
Writes a formatted string followed by a newline in the specified foreground color to the console asynchronously.
public Task WriteLineColorAsync(ConsoleColor foregroundColor, string value, params object[] args)
Parameters
foregroundColorConsoleColorThe foreground color.
valuestringThe string to write.
argsobject[]The format arguments.