예제 #1
0
        static void Main(string[] args)
        {
            FunctionHandlerWithTwoIntegerParametersThatReturnsVoid functionHandler;
            Calculator calc = new Calculator();

            functionHandler = new FunctionHandlerWithTwoIntegerParametersThatReturnsVoid(calc.AddTwoIntegerParameters);
            functionHandler += calc.MultiplyWithTwoIntegerParameters;
            functionHandler += calc.SubstractWithTwoIntegerParameters;
            functionHandler += calc.DivideWithTwoIntegerParameters;

            functionHandler.Invoke(2, 3);

            functionHandler -= calc.SubstractWithTwoIntegerParameters;

            functionHandler.Invoke(2, 3);
            
            //Console.WriteLine("What to do?");
            //Console.WriteLine("1. Add 2 and 3");
            //Console.WriteLine("2. Multiply 2 and 3");
            //ConsoleKeyInfo selected = Console.ReadKey(true);

            //Calculator calc = new Calculator();

            //switch (selected.Key)
            //{
            //    case ConsoleKey.NumPad1:
            //        functionHandler =  new FunctionHandlerWithTwoIntegerParametersThatReturnsVoid(calc.AddTwoIntegerParameters);
            //        break;
            //    case ConsoleKey.NumPad2:
            //        functionHandler =  new FunctionHandlerWithTwoIntegerParametersThatReturnsVoid(calc.MultiplyWithTwoIntegerParameters);
            //        break;
            //    default:
            //        functionHandler = new FunctionHandlerWithTwoIntegerParametersThatReturnsVoid(calc.MultiplyWithTwoIntegerParameters);
            //        break;
            //}

            //functionHandler.Invoke(2, 3);


            //ConsoleMenu mainMenu = new ConsoleMenu(
            //    new ConsoleMenu.ConsoleMenuItem[] 
            //    {
            //        new ConsoleMenu.ConsoleMenuItem() { Key = "1", Description = "Print hello world", Visible = true },
            //        new ConsoleMenu.ConsoleMenuItem() { Key = "2", Description = "Print goodbye world", Visible = false },
            //        new ConsoleMenu.ConsoleMenuItem() { Key = "3", Description = "Exit from menu", Visible = true }
            //    }
            //);

            //mainMenu.NextMenuItemKey = ConsoleKey.DownArrow;
            //mainMenu.PreviousMenuItemKey = ConsoleKey.UpArrow;
            //mainMenu.SelectMenuItemKey = ConsoleKey.Enter;

            //mainMenu.Display();


        }
예제 #2
0
        static void Main(string[] args)
        {
            FunctionHandlerWithTwoIntegerParametersThatReturnsVoid functionHandler;
            Calculator calc = new Calculator();

            functionHandler  = new FunctionHandlerWithTwoIntegerParametersThatReturnsVoid(calc.AddTwoIntegerParameters);
            functionHandler += calc.MultiplyWithTwoIntegerParameters;
            functionHandler += calc.SubstractWithTwoIntegerParameters;
            functionHandler += calc.DivideWithTwoIntegerParameters;

            functionHandler.Invoke(2, 3);

            functionHandler -= calc.SubstractWithTwoIntegerParameters;

            functionHandler.Invoke(2, 3);

            //Console.WriteLine("What to do?");
            //Console.WriteLine("1. Add 2 and 3");
            //Console.WriteLine("2. Multiply 2 and 3");
            //ConsoleKeyInfo selected = Console.ReadKey(true);

            //Calculator calc = new Calculator();

            //switch (selected.Key)
            //{
            //    case ConsoleKey.NumPad1:
            //        functionHandler =  new FunctionHandlerWithTwoIntegerParametersThatReturnsVoid(calc.AddTwoIntegerParameters);
            //        break;
            //    case ConsoleKey.NumPad2:
            //        functionHandler =  new FunctionHandlerWithTwoIntegerParametersThatReturnsVoid(calc.MultiplyWithTwoIntegerParameters);
            //        break;
            //    default:
            //        functionHandler = new FunctionHandlerWithTwoIntegerParametersThatReturnsVoid(calc.MultiplyWithTwoIntegerParameters);
            //        break;
            //}

            //functionHandler.Invoke(2, 3);


            //ConsoleMenu mainMenu = new ConsoleMenu(
            //    new ConsoleMenu.ConsoleMenuItem[]
            //    {
            //        new ConsoleMenu.ConsoleMenuItem() { Key = "1", Description = "Print hello world", Visible = true },
            //        new ConsoleMenu.ConsoleMenuItem() { Key = "2", Description = "Print goodbye world", Visible = false },
            //        new ConsoleMenu.ConsoleMenuItem() { Key = "3", Description = "Exit from menu", Visible = true }
            //    }
            //);

            //mainMenu.NextMenuItemKey = ConsoleKey.DownArrow;
            //mainMenu.PreviousMenuItemKey = ConsoleKey.UpArrow;
            //mainMenu.SelectMenuItemKey = ConsoleKey.Enter;

            //mainMenu.Display();
        }