From 5f5b96fffc2368b861e4f2b86bf7a1b05348afae Mon Sep 17 00:00:00 2001 From: Natalia Portillo Date: Sun, 6 Mar 2022 13:29:37 +0000 Subject: [PATCH] Move to file scoped namespaces. --- AaruConsole.cs | 327 ++++++++++++++++++++++++------------------------- 1 file changed, 163 insertions(+), 164 deletions(-) diff --git a/AaruConsole.cs b/AaruConsole.cs index c6e5642..a471a52 100644 --- a/AaruConsole.cs +++ b/AaruConsole.cs @@ -30,15 +30,113 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -namespace Aaru.Console +namespace Aaru.Console; + +/// +/// Writes the text representation of the specified array of objects, followed by the current line terminator, to +/// the standard output console using the specified format information. +/// +/// A composite format string. +/// An array of objects to write using . +public delegate void WriteLineHandler(string format, params object[] arg); + +/// +/// Writes the text representation of the specified array of objects, followed by the current line terminator, to +/// the error output console using the specified format information. +/// +/// A composite format string. +/// An array of objects to write using . +public delegate void ErrorWriteLineHandler(string format, params object[] arg); + +/// +/// Writes the text representation of the specified array of objects, followed by the current line terminator, to +/// the verbose output console using the specified format information. +/// +/// A composite format string. +/// An array of objects to write using . +public delegate void VerboseWriteLineHandler(string format, params object[] arg); + +/// +/// Writes the text representation of the specified array of objects, followed by the current line terminator, to +/// the debug output console using the specified format information. +/// +/// A composite format string. +/// An array of objects to write using . +public delegate void DebugWriteLineHandler(string format, params object[] arg); + +/// +/// Writes the text representation of the specified array of objects, to the standard output console using the +/// specified format information. +/// +/// A composite format string. +/// An array of objects to write using . +public delegate void WriteHandler(string format, params object[] arg); + +/// +/// Writes the text representation of the specified array of objects, to the error output console using the +/// specified format information. +/// +/// A composite format string. +/// An array of objects to write using . +public delegate void ErrorWriteHandler(string format, params object[] arg); + +/// +/// Writes the text representation of the specified array of objects, to the verbose output console using the +/// specified format information. +/// +/// A composite format string. +/// An array of objects to write using . +public delegate void VerboseWriteHandler(string format, params object[] arg); + +/// +/// Writes the text representation of the specified array of objects, to the debug output console using the +/// specified format information. +/// +/// A composite format string. +/// An array of objects to write using . +public delegate void DebugWriteHandler(string format, params object[] arg); + +/// +/// Writes the text representation of the specified array of objects, followed by the current line terminator, to +/// the debug output console using the specified format information. +/// +/// Description of the module writing to the debug console +/// A composite format string. +/// An array of objects to write using . +public delegate void DebugWithModuleWriteLineHandler(string module, string format, params object[] arg); + +/// +/// Implements a console abstraction that defines four level of messages that can be routed to different consoles: +/// standard, error, verbose and debug. +/// +public static class AaruConsole { + /// Event to receive writings to the standard output console that should be followed by a line termination. + public static event WriteLineHandler WriteLineEvent; + /// Event to receive writings to the error output console that should be followed by a line termination. + public static event ErrorWriteLineHandler ErrorWriteLineEvent; + /// Event to receive writings to the verbose output console that should be followed by a line termination. + public static event VerboseWriteLineHandler VerboseWriteLineEvent; + /// Event to receive line terminations to the debug output console. + public static event DebugWriteLineHandler DebugWriteLineEvent; + /// Event to receive writings to the debug output console that should be followed by a line termination. + public static event DebugWithModuleWriteLineHandler DebugWithModuleWriteLineEvent; + /// Event to receive writings to the standard output console. + public static event WriteHandler WriteEvent; + /// Event to receive writings to the error output console. + public static event ErrorWriteHandler ErrorWriteEvent; + /// Event to receive writings to the verbose output console. + public static event VerboseWriteHandler VerboseWriteEvent; + /// Event to receive writings to the debug output console. + public static event DebugWriteHandler DebugWriteEvent; + /// /// Writes the text representation of the specified array of objects, followed by the current line terminator, to /// the standard output console using the specified format information. /// /// A composite format string. /// An array of objects to write using . - public delegate void WriteLineHandler(string format, params object[] arg); + public static void WriteLine(string format, params object[] arg) => WriteLineEvent?.Invoke(format, arg); /// /// Writes the text representation of the specified array of objects, followed by the current line terminator, to @@ -46,7 +144,8 @@ namespace Aaru.Console /// /// A composite format string. /// An array of objects to write using . - public delegate void ErrorWriteLineHandler(string format, params object[] arg); + public static void ErrorWriteLine(string format, params object[] arg) => + ErrorWriteLineEvent?.Invoke(format, arg); /// /// Writes the text representation of the specified array of objects, followed by the current line terminator, to @@ -54,47 +153,8 @@ namespace Aaru.Console /// /// A composite format string. /// An array of objects to write using . - public delegate void VerboseWriteLineHandler(string format, params object[] arg); - - /// - /// Writes the text representation of the specified array of objects, followed by the current line terminator, to - /// the debug output console using the specified format information. - /// - /// A composite format string. - /// An array of objects to write using . - public delegate void DebugWriteLineHandler(string format, params object[] arg); - - /// - /// Writes the text representation of the specified array of objects, to the standard output console using the - /// specified format information. - /// - /// A composite format string. - /// An array of objects to write using . - public delegate void WriteHandler(string format, params object[] arg); - - /// - /// Writes the text representation of the specified array of objects, to the error output console using the - /// specified format information. - /// - /// A composite format string. - /// An array of objects to write using . - public delegate void ErrorWriteHandler(string format, params object[] arg); - - /// - /// Writes the text representation of the specified array of objects, to the verbose output console using the - /// specified format information. - /// - /// A composite format string. - /// An array of objects to write using . - public delegate void VerboseWriteHandler(string format, params object[] arg); - - /// - /// Writes the text representation of the specified array of objects, to the debug output console using the - /// specified format information. - /// - /// A composite format string. - /// An array of objects to write using . - public delegate void DebugWriteHandler(string format, params object[] arg); + public static void VerboseWriteLine(string format, params object[] arg) => + VerboseWriteLineEvent?.Invoke(format, arg); /// /// Writes the text representation of the specified array of objects, followed by the current line terminator, to @@ -103,134 +163,73 @@ namespace Aaru.Console /// Description of the module writing to the debug console /// A composite format string. /// An array of objects to write using . - public delegate void DebugWithModuleWriteLineHandler(string module, string format, params object[] arg); + public static void DebugWriteLine(string module, string format, params object[] arg) + { + DebugWriteLineEvent?.Invoke("DEBUG (" + module + "): " + format, arg); + DebugWithModuleWriteLineEvent?.Invoke(module, format, arg); + } + + /// Writes the current line terminator to the standard output console. + public static void WriteLine() => WriteLineEvent?.Invoke("", null); + + /// Writes the current line terminator to the error output console. + public static void ErrorWriteLine() => ErrorWriteLineEvent?.Invoke("", null); + + /// Writes the current line terminator to the verbose output console. + public static void VerboseWriteLine() => VerboseWriteLineEvent?.Invoke("", null); + + /// Writes the current line terminator to the debug output console. + public static void DebugWriteLine() => DebugWriteLineEvent?.Invoke("", null); /// - /// Implements a console abstraction that defines four level of messages that can be routed to different consoles: - /// standard, error, verbose and debug. + /// Writes the text representation of the specified array of objects to the standard output console using the + /// specified format information. /// - public static class AaruConsole - { - /// Event to receive writings to the standard output console that should be followed by a line termination. - public static event WriteLineHandler WriteLineEvent; - /// Event to receive writings to the error output console that should be followed by a line termination. - public static event ErrorWriteLineHandler ErrorWriteLineEvent; - /// Event to receive writings to the verbose output console that should be followed by a line termination. - public static event VerboseWriteLineHandler VerboseWriteLineEvent; - /// Event to receive line terminations to the debug output console. - public static event DebugWriteLineHandler DebugWriteLineEvent; - /// Event to receive writings to the debug output console that should be followed by a line termination. - public static event DebugWithModuleWriteLineHandler DebugWithModuleWriteLineEvent; - /// Event to receive writings to the standard output console. - public static event WriteHandler WriteEvent; - /// Event to receive writings to the error output console. - public static event ErrorWriteHandler ErrorWriteEvent; - /// Event to receive writings to the verbose output console. - public static event VerboseWriteHandler VerboseWriteEvent; - /// Event to receive writings to the debug output console. - public static event DebugWriteHandler DebugWriteEvent; + /// A composite format string. + /// An array of objects to write using . + public static void Write(string format, params object[] arg) => WriteEvent?.Invoke(format, arg); - /// - /// Writes the text representation of the specified array of objects, followed by the current line terminator, to - /// the standard output console using the specified format information. - /// - /// A composite format string. - /// An array of objects to write using . - public static void WriteLine(string format, params object[] arg) => WriteLineEvent?.Invoke(format, arg); + /// + /// Writes the text representation of the specified array of objects to the error output console using the + /// specified format information. + /// + /// A composite format string. + /// An array of objects to write using . + public static void ErrorWrite(string format, params object[] arg) => ErrorWriteEvent?.Invoke(format, arg); - /// - /// Writes the text representation of the specified array of objects, followed by the current line terminator, to - /// the error output console using the specified format information. - /// - /// A composite format string. - /// An array of objects to write using . - public static void ErrorWriteLine(string format, params object[] arg) => - ErrorWriteLineEvent?.Invoke(format, arg); + /// + /// Writes the text representation of the specified array of objects to the verbose output console using the + /// specified format information. + /// + /// A composite format string. + /// An array of objects to write using . + public static void VerboseWrite(string format, params object[] arg) => VerboseWriteEvent?.Invoke(format, arg); - /// - /// Writes the text representation of the specified array of objects, followed by the current line terminator, to - /// the verbose output console using the specified format information. - /// - /// A composite format string. - /// An array of objects to write using . - public static void VerboseWriteLine(string format, params object[] arg) => - VerboseWriteLineEvent?.Invoke(format, arg); + /// + /// Writes the text representation of the specified array of objects to the debug output console using the + /// specified format information. + /// + /// Description of the module writing to the debug console + /// A composite format string. + /// An array of objects to write using . + public static void DebugWrite(string module, string format, params object[] arg) => + DebugWriteEvent?.Invoke("DEBUG (" + module + "): " + format, arg); - /// - /// Writes the text representation of the specified array of objects, followed by the current line terminator, to - /// the debug output console using the specified format information. - /// - /// Description of the module writing to the debug console - /// A composite format string. - /// An array of objects to write using . - public static void DebugWriteLine(string module, string format, params object[] arg) - { - DebugWriteLineEvent?.Invoke("DEBUG (" + module + "): " + format, arg); - DebugWithModuleWriteLineEvent?.Invoke(module, format, arg); - } + /// Writes the specified string value, followed by the current line terminator, to the standard output console. + /// The value to write. + public static void WriteLine(string value) => WriteLineEvent?.Invoke("{0}", value); - /// Writes the current line terminator to the standard output console. - public static void WriteLine() => WriteLineEvent?.Invoke("", null); + /// Writes the specified string value, followed by the current line terminator, to the error output console. + /// The value to write. + public static void ErrorWriteLine(string value) => ErrorWriteLineEvent?.Invoke("{0}", value); - /// Writes the current line terminator to the error output console. - public static void ErrorWriteLine() => ErrorWriteLineEvent?.Invoke("", null); + /// Writes the specified string value, followed by the current line terminator, to the verbose output console. + /// The value to write. + public static void VerboseWriteLine(string value) => VerboseWriteLineEvent?.Invoke("{0}", value); - /// Writes the current line terminator to the verbose output console. - public static void VerboseWriteLine() => VerboseWriteLineEvent?.Invoke("", null); - - /// Writes the current line terminator to the debug output console. - public static void DebugWriteLine() => DebugWriteLineEvent?.Invoke("", null); - - /// - /// Writes the text representation of the specified array of objects to the standard output console using the - /// specified format information. - /// - /// A composite format string. - /// An array of objects to write using . - public static void Write(string format, params object[] arg) => WriteEvent?.Invoke(format, arg); - - /// - /// Writes the text representation of the specified array of objects to the error output console using the - /// specified format information. - /// - /// A composite format string. - /// An array of objects to write using . - public static void ErrorWrite(string format, params object[] arg) => ErrorWriteEvent?.Invoke(format, arg); - - /// - /// Writes the text representation of the specified array of objects to the verbose output console using the - /// specified format information. - /// - /// A composite format string. - /// An array of objects to write using . - public static void VerboseWrite(string format, params object[] arg) => VerboseWriteEvent?.Invoke(format, arg); - - /// - /// Writes the text representation of the specified array of objects to the debug output console using the - /// specified format information. - /// - /// Description of the module writing to the debug console - /// A composite format string. - /// An array of objects to write using . - public static void DebugWrite(string module, string format, params object[] arg) => - DebugWriteEvent?.Invoke("DEBUG (" + module + "): " + format, arg); - - /// Writes the specified string value, followed by the current line terminator, to the standard output console. - /// The value to write. - public static void WriteLine(string value) => WriteLineEvent?.Invoke("{0}", value); - - /// Writes the specified string value, followed by the current line terminator, to the error output console. - /// The value to write. - public static void ErrorWriteLine(string value) => ErrorWriteLineEvent?.Invoke("{0}", value); - - /// Writes the specified string value, followed by the current line terminator, to the verbose output console. - /// The value to write. - public static void VerboseWriteLine(string value) => VerboseWriteLineEvent?.Invoke("{0}", value); - - /// Writes the specified string value, followed by the current line terminator, to the debug output console. - /// Description of the module writing to the debug console - /// The value to write. - public static void DebugWriteLine(string module, string value) => - DebugWriteLineEvent?.Invoke("{0}", "DEBUG (" + module + "): " + value); - } + /// Writes the specified string value, followed by the current line terminator, to the debug output console. + /// Description of the module writing to the debug console + /// The value to write. + public static void DebugWriteLine(string module, string value) => + DebugWriteLineEvent?.Invoke("{0}", "DEBUG (" + module + "): " + value); } \ No newline at end of file