using Console.Waterworks.Constants ;
using Console.Waterworks.Loggers ;
using Console.Waterworks.Specialists ;
using System ;
using System.Collections.Generic ;
using System.Reflection ;
namespace Console.Waterworks.Assistants
{
class CoOrdinatorAssistant
{
internal void SetConsoleTitle ( CW_Logger logger , ProgramInfoSpecialist progInfoSpec , ConsoleIOSpecialist consoleSpec )
{
logger . LogInfoMessage ( "Attempting to set console title.." ) ;
var title = progInfoSpec . GetProductName ( ) ;
if ( ! string . IsNullOrEmpty ( title ) )
{
consoleSpec . SetConsoleTitle ( title ) ;
logger . LogSuccessMessage ( "Console title is now set" ) ;
}
else
logger . LogErrorMessage ( "Unable to determine the program's title. Check the manifest file to make sure it has been set" ) ;
}
internal void OutputProgramInfo ( CW_Logger logger , ProgramInfoSpecialist progInfoSpec , ConsoleIOSpecialist consoleSpec )
{
logger . LogInfoMessage ( "Attempting to retrieve program information.." ) ;
List < string > programInfo = progInfoSpec . GatherProgramInfomation ( ) ;
logger . LogInfoMessage ( $"Found {programInfo.Count} out of {CW_Constants.PROGRAM_INFO_PROPERTIES_COUNT} properties" ) ;
logger . LogInfoMessage ( $"Writing program properties to console.." ) ;
consoleSpec . WriteProgramInfo ( programInfo ) ;
}
internal void LogCommandGatheringAttempt ( List < Type > commandClasses , Dictionary < string , Dictionary < string , IEnumerable < ParameterInfo > > > commandLibraries , CW_Logger logger )
{
logger . LogInfoMessage ( $"Found {commandClasses.Count} command class(es).." ) ;
logger . LogInfoMessage ( $"Found {GetFoundCommandsTotal(commandLibraries)} command(s).." ) ;
logger . LogInfoMessage ( $"Found [{CW_Constants.COMMAND_CLASS_NAME}] class: { commandLibraries.ContainsKey(CW_Constants.COMMAND_CLASS_NAME)}" ) ;
logger . LogNoteMessage ( $"WaterWorks is only looking for the methods in the [{CW_Constants.COMMAND_CLASS_NAME}] class in the specified namespace. Everything else will be ignored" ) ;
logger . LogInfoMessage ( "Program is now initialised and awaiting input from the user. You are welcome ;-)" ) ;
}
internal int GetFoundCommandsTotal ( Dictionary < string , Dictionary < string , IEnumerable < ParameterInfo > > > commandLibraries )
{
int total = 0 ;
foreach ( var currentClass in commandLibraries . Values )
total + = currentClass . Count ;
return total ;
}
}
}