BadScript 2
Loading...
Searching...
No Matches
BadConsole.cs
Go to the documentation of this file.
1using System;
2using System.Threading.Tasks;
3
5
7
11public static class BadConsole
12{
13 public static readonly IBadConsole DummyConsole = new BadDummyConsole();
14
18 private static IBadConsole s_Console;
19
23 static BadConsole()
24 {
26 }
27
28
32 public static ConsoleColor ForegroundColor
33 {
35 set => s_Console.ForegroundColor = value;
36 }
37
41 public static ConsoleColor BackgroundColor
42 {
44 set => s_Console.BackgroundColor = value;
45 }
46
51 public static IBadConsole GetConsole()
52 {
53 return s_Console;
54 }
55
60 public static void SetConsole(IBadConsole console)
61 {
62 s_Console = console;
63 }
64
69 public static void Write(string str)
70 {
71 s_Console.Write(str);
72 }
73
78 public static void WriteLine(string str)
79 {
81 }
82
87 public static string ReadLine()
88 {
89 return s_Console.ReadLine();
90 }
91
96 public static Task<string> ReadLineAsync()
97 {
98 return s_Console.ReadLineAsync();
99 }
100
104 public static void Clear()
105 {
107 }
108
109#region Nested type: BadDummyConsole
110
112 {
113#region IBadConsole Members
114
115 public ConsoleColor ForegroundColor { get; set; }
116
117 public ConsoleColor BackgroundColor { get; set; }
118
119 public void Write(string str) { }
120
121 public void WriteLine(string str) { }
122
123 public string ReadLine()
124 {
125 throw new NotSupportedException();
126 }
127
128 public Task<string> ReadLineAsync()
129 {
130 throw new NotSupportedException();
131 }
132
133 public void Clear() { }
134
135#endregion
136 }
137
138#endregion
139}
void Write(string str)
Writes a string to the console.
Task< string > ReadLineAsync()
Reads a line from the console asynchronously.
void WriteLine(string str)
Writes a string to the console and appends a newline.
ConsoleColor ForegroundColor
The Foreground Color.
string ReadLine()
Reads a line from the console.
ConsoleColor BackgroundColor
The Background Color.
Wrapper class for the console abstraction.
Definition BadConsole.cs:12
static Task< string > ReadLineAsync()
Reads a line from the console asynchronously.
Definition BadConsole.cs:96
static void Clear()
Clears the console.
static string ReadLine()
Reads a line from the console.
Definition BadConsole.cs:87
static ConsoleColor BackgroundColor
The Background Color.
Definition BadConsole.cs:42
static IBadConsole s_Console
The Console Implementation that is used.
Definition BadConsole.cs:18
static void Write(string str)
Writes a string to the console.
Definition BadConsole.cs:69
static readonly IBadConsole DummyConsole
Definition BadConsole.cs:13
static void WriteLine(string str)
Writes a string to the console and appends a newline.
Definition BadConsole.cs:78
static IBadConsole GetConsole()
Returns the Current Console Implementation.
Definition BadConsole.cs:51
static BadConsole()
Static Constructor.
Definition BadConsole.cs:23
static ConsoleColor ForegroundColor
The Foreground Color.
Definition BadConsole.cs:33
static void SetConsole(IBadConsole console)
Sets the Current Console Implementation.
Definition BadConsole.cs:60
Implements a wrapper for the default system console.
Interface that abstracts the console.
void WriteLine(string str)
Writes a string to the console and appends a newline.
string ReadLine()
Reads a line from the console.
void Write(string str)
Writes a string to the console.
ConsoleColor ForegroundColor
The Foreground Color.
ConsoleColor BackgroundColor
The Background Color.
Task< string > ReadLineAsync()
Reads a line from the console asynchronously.
Contains Implementation of the Console Abstractions.
Contains a Console Abstraction Layer to be able to Simulate Console Input/Output over the Network.
Definition BadConsole.cs:6