コード例 #1
0
        public static Menu BuildMenu(Action <string> write, Action exitCallback)
        {
            var utility = new MenuUtility(write, exitCallback);
            var menu    = new Menu(new[] { "What math function would you like to use?" },
                                   new[] {
                new MenuItem()
                {
                    Key = "a", Text = "Add", Execute = utility.ChooseAdd
                },
                new MenuItem()
                {
                    Key = "s", Text = "Subtract", Execute = utility.ChooseSubtract
                },
                new MenuItem()
                {
                    Key = "m", Text = "Multiply", Execute = utility.ChooseMultiply
                },
                new MenuItem()
                {
                    Key = "d", Text = "Divide", Execute = utility.ChooseDivide
                },
                new MenuItem()
                {
                    Key = "e", Text = "Exit", Execute = utility.Exit
                }
            });

            return(menu);
        }
コード例 #2
0
 private static Menu BuildMainMenu()
 {
     return(MenuUtility.BuildMenu(Console.WriteLine, Exit));
 }