14[BadInteropApi(
"Console",
true)]
45 public Action<BadObject>
OnWrite {
get;
set; } = delegate { };
50 public Action<BadObject>
OnWriteLine {
get;
set; } = delegate { };
55 public Action
OnClear {
get;
set; } = delegate { };
60 public Func<string>
OnReadLine {
get;
set; } = () =>
string.Empty;
65 public Func<Task<string>>
OnReadLineAsync {
get;
set; } = () => System.Threading.Tasks.Task.FromResult(
string.Empty);
82 [BadMethod(
"WriteLine",
"Writes a line to the Console")]
88 [BadMethod(
"Write",
"Writes to the Console")]
94 [BadMethod(
"Clear",
"Clears the Console")]
100 [BadMethod(
"ReadLine",
"Reads a line from the Console")]
101 [
return: BadReturn(
"The Console Input")]
107 [BadMethod(
"ReadLineAsync",
"Reads a line from the Console asynchronously")]
108 [
return: BadReturn(
"The Console Input")]
113 "Console.ReadLineAsync"
125 while (!t.IsCompleted)
130 yield
return t.Result;
182 throw new NotSupportedException(
"Input is not allowed");
196 private readonly IEnumerator<BadObject>
m_Task;
Wrapper class for the console abstraction.
static IBadConsole GetConsole()
Returns the Current Console Implementation.
Awaitable Enumeration that wraps the ReadLineAsync Task.
override IEnumerator< BadObject > Enumerator
The Enumerator that wraps the Task.
override BadObject GetReturn()
The Return Value.
readonly IEnumerator< BadObject > m_Task
The Wrapped Task.
BadReadLineAsyncRunnable(IEnumerator< BadObject > task)
Constructs a new Instance.
BadObject m_Return
The Return Value.
Implements the "Console" API.
Func< string > OnReadLine
Event Handler for the "ReadLine" Function.
BadConsoleApi(IBadConsole console)
Constructs a new Console API Instance.
void WriteLine(BadObject obj)
Writes an Object to the Console. Appends a newline.
IEnumerable< BadObject > ReadLineAsyncBlocking()
Wrapper that will block until the Task is completed.
IBadConsole Console
The Console Implementation that is used.
Func< Task< string > > OnReadLineAsync
Event Handler for the "ReadLineAsync" Function.
void InvokeWrite([BadParameter(description:"The Object to Write")] BadObject obj)
bool AllowInput
If Set to false, the Console will throw an error if console input is requested.
BadTask InvokeReadLineAsync()
void InvokeWriteLine([BadParameter(description:"The Object to Write")] BadObject obj)
Action OnClear
Event Handler for the "Clear" Function.
void Clear()
Clears the Console.
Action< BadObject > OnWrite
Event Handler for the "Write" Function.
string ReadLine()
Reads a line from the Console.
Task< string > ReadLineAsync()
Wrapper that calls the "Write" Function in a new Task.
void Write(BadObject obj)
Writes an Object to the Console.
readonly? IBadConsole m_Console
The Console Implementation that is used.
Action< BadObject > OnWriteLine
Event Handler for the "WriteLine" Function.
Implements a Runnable Object.
Implements a Task Object.
The Base Class for all BadScript Objects.
override string ToString()
Returns a String Representation of this Object.
static readonly BadObject Null
The Null Value for the BadScript Language.
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.
void Clear()
Clears the console.
Implements the Interface for Native Strings.
Contains a Console Abstraction Layer to be able to Simulate Console Input/Output over the Network.
Contains Common Interop APIs for the BadScript2 Runtime.
Contains task/async Extensions and Integrations for the BadScript2 Runtime.
Contains the Native Runtime Objects.
Contains the Runtime Objects.