コード例 #1
0
        public override void Run(IAnsiConsole console)
        {
            var age      = 0;
            var name     = string.Empty;
            var sport    = string.Empty;
            var password = string.Empty;
            var color    = string.Empty;

            console.DisplayThenType(c => name     = AskName(c), "Peter F↲");
            console.DisplayThenType(c => sport    = AskSport(c), "football↲¦¦¦¦Hockey↲");
            console.DisplayThenType(c => age      = AskAge(c), "Forty↲¦¦¦¦40↲");
            console.DisplayThenType(c => password = AskPassword(c), "hunter2↲");
            console.DisplayThenType(c => color    = AskColor(c), "↲");

            AnsiConsole.Render(new Rule("[yellow]Results[/]").RuleStyle("grey").LeftAligned());
            AnsiConsole.Render(new Table().AddColumns("[grey]Question[/]", "[grey]Answer[/]")
                               .RoundedBorder()
                               .BorderColor(Color.Grey)
                               .AddRow("[grey]Name[/]", name)
                               .AddRow("[grey]Favorite sport[/]", sport)
                               .AddRow("[grey]Age[/]", age.ToString())
                               .AddRow("[grey]Password[/]", password)
                               .AddRow("[grey]Favorite color[/]", string.IsNullOrEmpty(color) ? "Unknown" : color));
        }