Exemplo n.º 1
0
        static void Main(string[] args)
        {
            // var ctx = new PaymentContext((EStrategy)1);
            // ctx.Execute();

            System.Console.WriteLine("Select strategy");
            ConsoleKeyInfo key;

            do
            {
                //while (!Console.KeyAvailable) {
                key = Console.ReadKey();
                System.Console.WriteLine();
                if (int.TryParse(key.KeyChar.ToString(), out var n))
                {
                    if (Enum.IsDefined(typeof(EStrategy), n))
                    {
                        var ctx = new PaymentContext((EStrategy)n);
                        ctx.Execute();
                    }
                    else
                    {
                        System.Console.WriteLine("Wrong type");
                    }
                }
                //}
            } while (key.Key != ConsoleKey.Escape);
        }