private MasterConfigurationModel LoadConfiguration() { while (true) { try { var config = UnityContainer.Resolve <MasterConfigurationModel>(); if (config == null) { Console.WriteLine(@"Master configuration file '{0}' was not loaded. Try running this program with argument --help.", RunConfigurationModel.MasterConfiguration); WaitForAnyKeyToReloadConfiguration(); continue; } Console.WriteLine(@"Configuration was loaded."); return(config); } catch (Exception e) { using (ConsoleColorClosure.ForegroundColor(ConsoleColor.Red)) { Console.WriteLine(@"An error occured while loading master configuration:"); Console.WriteLine((e.InnerException as JsonReaderException)?.Message ?? e.Message); } WaitForAnyKeyToReloadConfiguration(); } } }
private static void ColorConsole(ConsoleColor color, Action action) { using (ConsoleColorClosure.ForegroundColor(color)) action(); }