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;
6
8{
13 public static class ConsoleError
14 {
18 public static Encoding Encoding => System.Console.Error.Encoding;
19
23 public static IFormatProvider FormatProvider => System.Console.Error.FormatProvider;
24
28 public static string NewLine => System.Console.Error.NewLine;
29
34 public static void Write(string value)
35 {
36 if (!string.IsNullOrEmpty(value))
38 }
39
44 public static void Write(CustomWriter Writer)
45 {
46 Write(Writer, null, null);
47 }
48
55 public static void Write(CustomWriter Writer, ConsoleColor? ForegroundColor, ConsoleColor? BackgroundColor)
56 {
57 ConsoleWorker.Queue(new ConsoleErrorCustomWriter(Writer, ForegroundColor, BackgroundColor));
58 }
59
64 public static void Write(ulong value)
65 {
66 Write(value.ToString());
67 }
68
73 public static void Write(uint value)
74 {
75 Write(value.ToString());
76 }
77
83 public static void Write(string format, params object[] arg)
84 {
85 Write(string.Format(format, arg));
86 }
87
95 public static void Write(string format, object arg0, object arg1, object arg2)
96 {
97 Write(string.Format(format, arg0, arg1, arg2));
98 }
99
106 public static void Write(string format, object arg0, object arg1)
107 {
108 Write(string.Format(format, arg0, arg1));
109 }
110
116 public static void Write(string format, object arg0)
117 {
118 Write(string.Format(format, arg0));
119 }
120
125 public static void Write(float value)
126 {
127 Write(value.ToString());
128 }
129
134 public static void Write(long value)
135 {
136 Write(value.ToString());
137 }
138
143 public static void Write(int value)
144 {
145 Write(value.ToString());
146 }
147
152 public static void Write(double value)
153 {
154 Write(value.ToString());
155 }
156
161 public static void Write(decimal value)
162 {
163 Write(value.ToString());
164 }
165
172 public static void Write(char[] buffer, int index, int count)
173 {
174 Write(new string(buffer, index, count));
175 }
176
181 public static void Write(char[] buffer)
182 {
183 Write(new string(buffer));
184 }
185
190 public static void Write(char value)
191 {
192 Write(new string(value, 1));
193 }
194
199 public static void Write(bool value)
200 {
201 Write(value.ToString());
202 }
203
208 public static void Write(object value)
209 {
210 if (!(value is null))
211 Write(value.ToString());
212 }
213
218 public static async Task WriteAsync(string value)
219 {
220 if (!string.IsNullOrEmpty(value))
221 {
222 WorkItem Item = new ConsoleErrorWriteString(value.ToString());
223
224 if (!await ConsoleWorker.Queue(Item))
225 return;
226
227 await Item.Wait();
228 }
229 }
230
237 public static Task WriteAsync(char[] buffer, int index, int count)
238 {
239 return WriteAsync(new string(buffer, index, count));
240 }
241
246 public static Task WriteAsync(char[] buffer)
247 {
248 return WriteAsync(new string(buffer));
249 }
250
255 public static Task WriteAsync(char value)
256 {
257 return WriteAsync(new string(value, 1));
258 }
259
265 {
266 return WriteAsync(Writer, null, null);
267 }
268
275 public static async Task WriteAsync(CustomAsyncWriter Writer, ConsoleColor? ForegroundColor, ConsoleColor? BackgroundColor)
276 {
277 WorkItem Item = new ConsoleErrorCustomAsyncWriter(Writer, ForegroundColor, BackgroundColor);
278
279 if (!await ConsoleWorker.Queue(Item))
280 return;
281
282 await Item.Wait();
283 }
284
288 public static void WriteLine()
289 {
290 WriteLine(string.Empty);
291 }
292
297 public static void WriteLine(string value)
298 {
300 }
301
306 public static void WriteLine(ulong value)
307 {
308 WriteLine(value.ToString());
309 }
310
315 public static void WriteLine(uint value)
316 {
317 WriteLine(value.ToString());
318 }
319
325 public static void WriteLine(string format, params object[] arg)
326 {
327 WriteLine(string.Format(format, arg));
328 }
329
337 public static void WriteLine(string format, object arg0, object arg1, object arg2)
338 {
339 WriteLine(string.Format(format, arg0, arg1, arg2));
340 }
341
348 public static void WriteLine(string format, object arg0, object arg1)
349 {
350 WriteLine(string.Format(format, arg0, arg1));
351 }
352
357 public static void WriteLine(float value)
358 {
359 WriteLine(value.ToString());
360 }
361
367 public static void WriteLine(string format, object arg0)
368 {
369 WriteLine(string.Format(format, arg0));
370 }
371
376 public static void WriteLine(long value)
377 {
378 WriteLine(value.ToString());
379 }
380
385 public static void WriteLine(int value)
386 {
387 WriteLine(value.ToString());
388 }
389
394 public static void WriteLine(double value)
395 {
396 WriteLine(value.ToString());
397 }
398
403 public static void WriteLine(decimal value)
404 {
405 WriteLine(value.ToString());
406 }
407
414 public static void WriteLine(char[] buffer, int index, int count)
415 {
416 WriteLine(new string(buffer, index, count));
417 }
418
423 public static void WriteLine(char[] buffer)
424 {
425 WriteLine(new string(buffer));
426 }
427
432 public static void WriteLine(char value)
433 {
434 WriteLine(new string(value, 1));
435 }
436
441 public static void WriteLine(object value)
442 {
443 if (!(value is null))
444 WriteLine(value.ToString());
445 }
446
451 public static void WriteLine(bool value)
452 {
453 WriteLine(value.ToString());
454 }
455
460 public static async Task WriteLineAsync(string value)
461 {
462 WorkItem Item = new ConsoleErrorWriteLineString(value ?? string.Empty);
463
464 if (!await ConsoleWorker.Queue(Item))
465 return;
466
467 await Item.Wait();
468 }
469
473 public static Task WriteLineAsync()
474 {
475 return WriteLineAsync(string.Empty);
476 }
477
482 public static Task WriteLineAsync(char value)
483 {
484 return WriteLineAsync(new string(value, 1));
485 }
486
491 public static Task WriteLineAsync(char[] buffer)
492 {
493 return WriteLineAsync(new string(buffer));
494 }
495
502 public static Task WriteLineAsync(char[] buffer, int index, int count)
503 {
504 return WriteLineAsync(new string(buffer, index, count));
505 }
506
510 public static void Beep()
511 {
513 }
514
518 public static TextWriter Writer
519 {
520 get => new ConsoleErrorTextWriter();
521 }
522
526 private class ConsoleErrorTextWriter : TextWriter
527 {
528 public ConsoleErrorTextWriter()
529 {
530 }
531
532 public override Encoding Encoding => ConsoleError.Encoding;
533 public override void Write(char value) => ConsoleError.Write(value);
534 public override void Write(ulong value) => ConsoleError.Write(value);
535 public override void Write(uint value) => ConsoleError.Write(value);
536 public override void Write(string format, params object[] arg) => ConsoleError.Write(format, arg);
537 public override void Write(string format, object arg0, object arg1, object arg2) => ConsoleError.Write(format, arg0, arg1, arg2);
538 public override void Write(string format, object arg0, object arg1) => ConsoleError.Write(format, arg0, arg1);
539 public override void Write(string format, object arg0) => ConsoleError.Write(format, arg0);
540 public override void Write(string value) => ConsoleError.Write(value);
541 public override void Write(float value) => ConsoleError.Write(value);
542 public override void Write(long value) => ConsoleError.Write(value);
543 public override void Write(int value) => ConsoleError.Write(value);
544 public override void Write(double value) => ConsoleError.Write(value);
545 public override void Write(decimal value) => ConsoleError.Write(value);
546 public override void Write(char[] buffer, int index, int count) => ConsoleError.Write(buffer, index, count);
547 public override void Write(char[] buffer) => ConsoleError.Write(buffer);
548 public override void Write(bool value) => ConsoleError.Write(value);
549 public override void Write(object value) => ConsoleError.Write(value);
550 public override Task WriteAsync(string value) => ConsoleError.WriteAsync(value);
551 public override Task WriteAsync(char[] buffer, int index, int count) => ConsoleError.WriteAsync(buffer, index, count);
552 public override Task WriteAsync(char value) => ConsoleError.WriteAsync(value);
553 public override void WriteLine() => ConsoleError.WriteLine();
554 public override void WriteLine(ulong value) => ConsoleError.WriteLine(value);
555 public override void WriteLine(uint value) => ConsoleError.WriteLine(value);
556 public override void WriteLine(string format, params object[] arg) => ConsoleError.WriteLine(format, arg);
557 public override void WriteLine(string format, object arg0, object arg1, object arg2) => ConsoleError.WriteLine(format, arg0, arg1, arg2);
558 public override void WriteLine(string format, object arg0, object arg1) => ConsoleError.WriteLine(format, arg0, arg1);
559 public override void WriteLine(string value) => ConsoleError.WriteLine(value);
560 public override void WriteLine(float value) => ConsoleError.WriteLine(value);
561 public override void WriteLine(string format, object arg0) => ConsoleError.WriteLine(format, arg0);
562 public override void WriteLine(long value) => ConsoleError.WriteLine(value);
563 public override void WriteLine(int value) => ConsoleError.WriteLine(value);
564 public override void WriteLine(double value) => ConsoleError.WriteLine(value);
565 public override void WriteLine(decimal value) => ConsoleError.WriteLine(value);
566 public override void WriteLine(char[] buffer, int index, int count) => ConsoleError.WriteLine(buffer, index, count);
567 public override void WriteLine(char[] buffer) => ConsoleError.WriteLine(buffer);
568 public override void WriteLine(char value) => ConsoleError.WriteLine(value);
569 public override void WriteLine(object value) => ConsoleError.WriteLine(value);
570 public override void WriteLine(bool value) => ConsoleError.WriteLine(value);
571 public override Task WriteLineAsync() => ConsoleError.WriteLineAsync();
572 public override Task WriteLineAsync(char value) => ConsoleError.WriteLineAsync(value);
573 public override Task WriteLineAsync(char[] buffer, int index, int count) => ConsoleError.WriteLineAsync(buffer, index, count);
574 public override Task WriteLineAsync(string value) => ConsoleError.WriteLineAsync(value);
575 }
576 }
577}
Serializes output to System.Console.Error, and assures modules are not dead-locked in case the Consol...
Definition: ConsoleError.cs:14
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:64
static Encoding Encoding
The character encoding in which the output is written.
Definition: ConsoleError.cs:18
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:73
static void Write(CustomWriter Writer)
Queues a custom writer to the console output.
Definition: ConsoleError.cs:44
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:95
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:55
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:83
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:34
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:28
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:23
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 > Queue(WorkItem Work)
Queues a work item.
Manages a Console operation.
Definition: WorkItem.cs:9
Task< bool > Wait()
Waits for the item to be processed.
Definition: WorkItem.cs:30
delegate void CustomWriter(TextWriter Output)
Delegate for custom writers.
delegate Task CustomAsyncWriter(TextWriter Output)
Delegate for asynchronous custom writers.