示例#1
0
        private static void HandleUserInteraction(IUI ui, Dictionary <string, UiOption> uiOptions)
        {
            UiOption uiOption = null;

            ui.Output(new string('-', 40));

            foreach (KeyValuePair <string, UiOption> option in uiOptions)
            {
                ui.Output($"({option.Key}) - {option.Value.Text}");
            }

            string input = ui.Input("Select an option:", null);

            if (!string.IsNullOrEmpty(input) && uiOptions.TryGetValue(input, out uiOption))
            {
                uiOption.Action();
            }
            else
            {
                ui.Output("Option does not exist");
            }
        }