public void RenderUseCases(UseCaseCategory category) { while (true) { var useCases = category.GetUseCases(); ShowSplash(); Console.WriteLine($"Use cases in category '{category.Name}':"); for (var i = 0; i < useCases.Length; i++) { Console.WriteLine($" {i+1}. {useCases[i].Name}"); } Console.WriteLine(" Q. Quit to categories list"); Console.WriteLine(); Console.Write("? "); var input = Console.ReadLine(); if (input.ToLower() == "q") { return; } if (int.TryParse(input, out var useCaseIndex) && useCaseIndex >= 1 && useCaseIndex <= useCases.Length) { Console.Clear(); useCases[useCaseIndex - 1].Execute(); Console.ReadLine(); } } }
public void RenderUseCases(UseCaseCategory category) { var useCases = category.GetUseCases(); while (true) { var selected = MenuHelper.Choice( () => { Console.Write("Choose a use cases in category '"); Console.ForegroundColor = Constants.PrimaryColor; Console.Write(category.Name); Console.ResetColor(); Console.WriteLine("':"); Console.WriteLine(); }, useCases .Select((useCase, i) => $"{i + 1}. {useCase.Name}") .Append("<- Back") .ToArray()); if (selected < 0 || selected >= useCases.Length) { return; } Console.Clear(); useCases[selected].Execute(); Console.ForegroundColor = Constants.PrimaryColor; Console.Write("\r\nPress any key to continue..."); Console.ResetColor(); Console.ReadLine(); } }