Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
ConsoleError.cs
1using System;
2using System.IO;
3using System.Text;
4using System.Threading.Tasks;
7
9{
14 public static class ConsoleError
15 {
19 public static Encoding Encoding => System.Console.Error.Encoding;
20
24 public static IFormatProvider FormatProvider => System.Console.Error.FormatProvider;
25
29 public static string NewLine => System.Console.Error.NewLine;
30
35 public static void Write(string value)
36 {
37 if (!string.IsNullOrEmpty(value))
39 }
40
45 public static void Write(CustomWriter Writer)
46 {
47 Write(Writer, null, null);
48 }
49
56 public static void Write(CustomWriter Writer, ConsoleColor? ForegroundColor, ConsoleColor? BackgroundColor)
57 {
58 ConsoleWorker.Forward(new ConsoleErrorCustomWriter(Writer, ForegroundColor, BackgroundColor));
59 }
60
65 public static void Write(ulong value)
66 {
67 Write(value.ToString());
68 }
69
74 public static void Write(uint value)
75 {
76 Write(value.ToString());
77 }
78
84 public static void Write(string format, params object[] arg)
85 {
86 Write(string.Format(format, arg));
87 }
88
96 public static void Write(string format, object arg0, object arg1, object arg2)
97 {
98 Write(string.Format(format, arg0, arg1, arg2));
99 }
100
107 public static void Write(string format, object arg0, object arg1)
108 {
109 Write(string.Format(format, arg0, arg1));
110 }
111
117 public static void Write(string format, object arg0)
118 {
119 Write(string.Format(format, arg0));
120 }
121
126 public static void Write(float value)
127 {
128 Write(value.ToString());
129 }
130
135 public static void Write(long value)
136 {
137 Write(value.ToString());
138 }
139
144 public static void Write(int value)
145 {
146 Write(value.ToString());
147 }
148
153 public static void Write(double value)
154 {
155 Write(value.ToString());
156 }
157
162 public static void Write(decimal value)
163 {
164 Write(value.ToString());
165 }
166
173 public static void Write(char[] buffer, int index, int count)
174 {
175 Write(new string(buffer, index, count));
176 }
177
182 public static void Write(char[] buffer)
183 {
184 Write(new string(buffer));
185 }
186
191 public static void Write(char value)
192 {
193 Write(new string(value, 1));
194 }
195
200 public static void Write(bool value)
201 {
202 Write(value.ToString());
203 }
204
209 public static void Write(object value)
210 {
211 if (!(value is null))
212 Write(value.ToString());
213 }
214
219 public static async Task WriteAsync(string value)
220 {
221 if (!string.IsNullOrEmpty(value))
222 {
223 WorkItem Item = new ConsoleErrorWriteString(value.ToString());
224
225 if (!await ConsoleWorker.Forward(Item))
226 return;
227
228 await Item.Wait();
229 }
230 }
231
238 public static Task WriteAsync(char[] buffer, int index, int count)
239 {
240 return WriteAsync(new string(buffer, index, count));
241 }
242
247 public static Task WriteAsync(char[] buffer)
248 {
249 return WriteAsync(new string(buffer));
250 }
251
256 public static Task WriteAsync(char value)
257 {
258 return WriteAsync(new string(value, 1));
259 }
260
266 {
267 return WriteAsync(Writer, null, null);
268 }
269
276 public static async Task WriteAsync(CustomAsyncWriter Writer, ConsoleColor? ForegroundColor, ConsoleColor? BackgroundColor)
277 {
278 WorkItem Item = new ConsoleErrorCustomAsyncWriter(Writer, ForegroundColor, BackgroundColor);
279
280 if (!await ConsoleWorker.Forward(Item))
281 return;
282
283 await Item.Wait();
284 }
285
289 public static void WriteLine()
290 {
291 WriteLine(string.Empty);
292 }
293
298 public static void WriteLine(string value)
299 {
301 }
302
307 public static void WriteLine(ulong value)
308 {
309 WriteLine(value.ToString());
310 }
311
316 public static void WriteLine(uint value)
317 {
318 WriteLine(value.ToString());
319 }
320
326 public static void WriteLine(string format, params object[] arg)
327 {
328 WriteLine(string.Format(format, arg));
329 }
330
338 public static void WriteLine(string format, object arg0, object arg1, object arg2)
339 {
340 WriteLine(string.Format(format, arg0, arg1, arg2));
341 }
342
349 public static void WriteLine(string format, object arg0, object arg1)
350 {
351 WriteLine(string.Format(format, arg0, arg1));
352 }
353
358 public static void WriteLine(float value)
359 {
360 WriteLine(value.ToString());
361 }
362
368 public static void WriteLine(string format, object arg0)
369 {
370 WriteLine(string.Format(format, arg0));
371 }
372
377 public static void WriteLine(long value)
378 {
379 WriteLine(value.ToString());
380 }
381
386 public static void WriteLine(int value)
387 {
388 WriteLine(value.ToString());
389 }
390
395 public static void WriteLine(double value)
396 {
397 WriteLine(value.ToString());
398 }
399
404 public static void WriteLine(decimal value)
405 {
406 WriteLine(value.ToString());
407 }
408
415 public static void WriteLine(char[] buffer, int index, int count)
416 {
417 WriteLine(new string(buffer, index, count));
418 }
419
424 public static void WriteLine(char[] buffer)
425 {
426 WriteLine(new string(buffer));
427 }
428
433 public static void WriteLine(char value)
434 {
435 WriteLine(new string(value, 1));
436 }
437
442 public static void WriteLine(object value)
443 {
444 if (!(value is null))
445 WriteLine(value.ToString());
446 }
447
452 public static void WriteLine(bool value)
453 {
454 WriteLine(value.ToString());
455 }
456
461 public static async Task WriteLineAsync(string value)
462 {
463 WorkItem Item = new ConsoleErrorWriteLineString(value ?? string.Empty);
464
465 if (!await ConsoleWorker.Forward(Item))
466 return;
467
468 await Item.Wait();
469 }
470
474 public static Task WriteLineAsync()
475 {
476 return WriteLineAsync(string.Empty);
477 }
478
483 public static Task WriteLineAsync(char value)
484 {
485 return WriteLineAsync(new string(value, 1));
486 }
487
492 public static Task WriteLineAsync(char[] buffer)
493 {
494 return WriteLineAsync(new string(buffer));
495 }
496
503 public static Task WriteLineAsync(char[] buffer, int index, int count)
504 {
505 return WriteLineAsync(new string(buffer, index, count));
506 }
507
511 public static void Beep()
512 {
514 }
515
519 public static TextWriter Writer
520 {
521 get => new ConsoleErrorTextWriter();
522 }
523
527 private class ConsoleErrorTextWriter : TextWriter
528 {
529 public ConsoleErrorTextWriter()
530 {
531 }
532
533 public override Encoding Encoding => ConsoleError.Encoding;
534 public override void Write(char value) => ConsoleError.Write(value);
535 public override void Write(ulong value) => ConsoleError.Write(value);
536 public override void Write(uint value) => ConsoleError.Write(value);
537 public override void Write(string format, params object[] arg) => ConsoleError.Write(format, arg);
538 public override void Write(string format, object arg0, object arg1, object arg2) => ConsoleError.Write(format, arg0, arg1, arg2);
539 public override void Write(string format, object arg0, object arg1) => ConsoleError.Write(format, arg0, arg1);
540 public override void Write(string format, object arg0) => ConsoleError.Write(format, arg0);
541 public override void Write(string value) => ConsoleError.Write(value);
542 public override void Write(float value) => ConsoleError.Write(value);
543 public override void Write(long value) => ConsoleError.Write(value);
544 public override void Write(int value) => ConsoleError.Write(value);
545 public override void Write(double value) => ConsoleError.Write(value);
546 public override void Write(decimal value) => ConsoleError.Write(value);
547 public override void Write(char[] buffer, int index, int count) => ConsoleError.Write(buffer, index, count);
548 public override void Write(char[] buffer) => ConsoleError.Write(buffer);
549 public override void Write(bool value) => ConsoleError.Write(value);
550 public override void Write(object value) => ConsoleError.Write(value);
551 public override Task WriteAsync(string value) => ConsoleError.WriteAsync(value);
552 public override Task WriteAsync(char[] buffer, int index, int count) => ConsoleError.WriteAsync(buffer, index, count);
553 public override Task WriteAsync(char value) => ConsoleError.WriteAsync(value);
554 public override void WriteLine() => ConsoleError.WriteLine();
555 public override void WriteLine(ulong value) => ConsoleError.WriteLine(value);
556 public override void WriteLine(uint value) => ConsoleError.WriteLine(value);
557 public override void WriteLine(string format, params object[] arg) => ConsoleError.WriteLine(format, arg);
558 public override void WriteLine(string format, object arg0, object arg1, object arg2) => ConsoleError.WriteLine(format, arg0, arg1, arg2);
559 public override void WriteLine(string format, object arg0, object arg1) => ConsoleError.WriteLine(format, arg0, arg1);
560 public override void WriteLine(string value) => ConsoleError.WriteLine(value);
561 public override void WriteLine(float value) => ConsoleError.WriteLine(value);
562 public override void WriteLine(string format, object arg0) => ConsoleError.WriteLine(format, arg0);
563 public override void WriteLine(long value) => ConsoleError.WriteLine(value);
564 public override void WriteLine(int value) => ConsoleError.WriteLine(value);
565 public override void WriteLine(double value) => ConsoleError.WriteLine(value);
566 public override void WriteLine(decimal value) => ConsoleError.WriteLine(value);
567 public override void WriteLine(char[] buffer, int index, int count) => ConsoleError.WriteLine(buffer, index, count);
568 public override void WriteLine(char[] buffer) => ConsoleError.WriteLine(buffer);
569 public override void WriteLine(char value) => ConsoleError.WriteLine(value);
570 public override void WriteLine(object value) => ConsoleError.WriteLine(value);
571 public override void WriteLine(bool value) => ConsoleError.WriteLine(value);
572 public override Task WriteLineAsync() => ConsoleError.WriteLineAsync();
573 public override Task WriteLineAsync(char value) => ConsoleError.WriteLineAsync(value);
574 public override Task WriteLineAsync(char[] buffer, int index, int count) => ConsoleError.WriteLineAsync(buffer, index, count);
575 public override Task WriteLineAsync(string value) => ConsoleError.WriteLineAsync(value);
576 }
577 }
578}
Serializes output to System.Console.Error, and assures modules are not dead-locked in case the Consol...
Definition: ConsoleError.cs:15
static void Beep()
Emits a Beep sounds.
static Task WriteAsync(CustomAsyncWriter Writer)
Queues a custom writer to the console output.
static void Write(ulong value)
Queues a value to be written to the console output.
Definition: ConsoleError.cs:65
static Encoding Encoding
The character encoding in which the output is written.
Definition: ConsoleError.cs:19
static void WriteLine(char[] buffer)
Queues a value to be written to the console output.
static Task WriteLineAsync(char value)
Queues a value to be written to the console output.
static void Write(long value)
Queues a value to be written to the console output.
static void WriteLine(object value)
Queues a value to be written to the console output.
static async Task WriteAsync(CustomAsyncWriter Writer, ConsoleColor? ForegroundColor, ConsoleColor? BackgroundColor)
Queues a custom writer to the console output.
static void WriteLine(double value)
Queues a value to be written to the console output.
static void WriteLine(ulong value)
Queues a value to be written to the console output.
static void WriteLine(char[] buffer, int index, int count)
Queues a value to be written to the console output.
static void Write(uint value)
Queues a value to be written to the console output.
Definition: ConsoleError.cs:74
static void Write(CustomWriter Writer)
Queues a custom writer to the console output.
Definition: ConsoleError.cs:45
static void WriteLine(int value)
Queues a value to be written to the console output.
static async Task WriteLineAsync(string value)
Queues a value to be written to the console output.
static void WriteLine(decimal value)
Queues a value to be written to the console output.
static async Task WriteAsync(string value)
Queues a value to be written to the console output.
static void WriteLine()
Queues a value to be written to the console output.
static TextWriter Writer
Provides a TextWriter instance, that writes to ConsoleError.
static void Write(float value)
Queues a value to be written to the console output.
static void Write(int value)
Queues a value to be written to the console output.
static void WriteLine(bool value)
Queues a value to be written to the console output.
static void Write(string format, object arg0, object arg1, object arg2)
Queues a value to be written to the console output.
Definition: ConsoleError.cs:96
static void WriteLine(long value)
Queues a value to be written to the console output.
static void Write(bool value)
Queues a value to be written to the console output.
static void Write(string format, object arg0)
Queues a value to be written to the console output.
static void Write(object value)
Queues a value to be written to the console output.
static void WriteLine(string value)
Queues a value to be written to the console output.
static void Write(string format, object arg0, object arg1)
Queues a value to be written to the console output.
static Task WriteAsync(char value)
Queues a value to be written to the console output.
static void WriteLine(char value)
Queues a value to be written to the console output.
static void Write(CustomWriter Writer, ConsoleColor? ForegroundColor, ConsoleColor? BackgroundColor)
Queues a custom writer to the console output.
Definition: ConsoleError.cs:56
static Task WriteLineAsync(char[] buffer)
Queues a value to be written to the console output.
static Task WriteLineAsync()
Queues a value to be written to the console output.
static void Write(char[] buffer)
Queues a value to be written to the console output.
static void Write(string format, params object[] arg)
Queues a value to be written to the console output.
Definition: ConsoleError.cs:84
static void Write(char[] buffer, int index, int count)
Queues a value to be written to the console output.
static void Write(string value)
Queues a value to be written to the console output.
Definition: ConsoleError.cs:35
static void Write(char value)
Queues a value to be written to the console output.
static void WriteLine(string format, object arg0, object arg1)
Queues a value to be written to the console output.
static void WriteLine(string format, object arg0, object arg1, object arg2)
Queues a value to be written to the console output.
static string NewLine
The line terminator string for the current TextWriter.
Definition: ConsoleError.cs:29
static void WriteLine(string format, object arg0)
Queues a value to be written to the console output.
static void WriteLine(float value)
Queues a value to be written to the console output.
static void Write(decimal value)
Queues a value to be written to the console output.
static void WriteLine(string format, params object[] arg)
Queues a value to be written to the console output.
static IFormatProvider FormatProvider
Gets an object that controls formatting.
Definition: ConsoleError.cs:24
static Task WriteAsync(char[] buffer, int index, int count)
Queues a value to be written to the console output.
static Task WriteAsync(char[] buffer)
Queues a value to be written to the console output.
static Task WriteLineAsync(char[] buffer, int index, int count)
Queues a value to be written to the console output.
static void WriteLine(uint value)
Queues a value to be written to the console output.
static void Write(double value)
Queues a value to be written to the console output.
Writes a string to the console, appending a newline at the end.
Processes console tasks, such as input and output, in a serialized asynchronous manner.
static Task< bool > Forward(WorkItem Work)
Forwards a work item for processing.
Represents an asynchronous operation to be performed.
Definition: WorkItem.cs:10
Task< bool > Wait()
Waits for the item to be processed.
Definition: WorkItem.cs:40
delegate void CustomWriter(TextWriter Output)
Delegate for custom writers.
delegate Task CustomAsyncWriter(TextWriter Output)
Delegate for asynchronous custom writers.