//\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
// AFXUI auxiliary module for Blazor-application (WASM) | Author: Sergei Y.Kitáev
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
using System;
using System.Text;

using CommonHelpers.WASM;

namespace AFXUI {

//**************************************************************************************************
public static class UConsole {
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

public static void Print( string message ) =>
   Console.WriteLine( HString.ToWebText( message ) );
public static void Print( string messageFmt, params object?[] parameters ) =>
   Print( HString.FormatAsText( messageFmt, parameters ) );

//--------------------------------------------------------------------------------------------------

public static void PrintError( string message ) =>
   UJS.Invoke( "Console_PrintError", HString.ToWebText( message ) );
public static void PrintError( string messageFmt, params object?[] parameters ) =>
   PrintError( HString.FormatAsText( messageFmt, parameters ) );

public static void PrintError( Exception error ) =>
   PrintError( null, error );
public static void PrintError( string? captionLine, Exception error )
{
   var sb = new StringBuilder();
   if ( captionLine != null )
      sb.AppendLine( captionLine );
   sb.Append( HException.ComposeChainedMessage( error ) );
   PrintError( sb.ToString() );
}

//--------------------------------------------------------------------------------------------------

public static void PrintOperation( string message ) =>
   Console.WriteLine( "* {0} ...", HString.ToWebText( message ) );
public static void PrintOperation( string messageFmt, params object?[] parameters ) =>
   PrintOperation( HString.FormatAsText( messageFmt, parameters ) );

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
} // UConsole
//**************************************************************************************************

} // AFXUI
