Exemplo n.º 1
0
        public static void Main()
        {
            StringBuilder output = new StringBuilder();Catalog cat = new Catalog();
            ICommandExecutor c = new CommandExecutor();

            foreach (ICommand item in parse())
            {
                c.ExecuteCommand(cat, item, output); //this is how we do

            }

            //Console.BackgroundColor = ConsoleColor.DarkGreen;
            Console.Write(output
                ); //printing the output
        }
Exemplo n.º 2
0
        public static void Main()
        {
            StringBuilder output = new StringBuilder();
            Catalog catalog = new Catalog();
            ICommandExecutor commandExecutor = new CommandExecutor();

            foreach (ICommand item in ParseCommands())
            {
                commandExecutor.ExecuteCommand(catalog, item, output);
            }

            //redirect console
            FileStream ostrm;
            StreamWriter writer;
            TextWriter oldOut = Console.Out;
            try
            {
                ostrm = new FileStream("C:/Users/User/Desktop/Redirect.txt", FileMode.OpenOrCreate, FileAccess.Write);
                writer = new StreamWriter(ostrm);
            }
            catch (Exception e)
            {
                Console.WriteLine("Cannot open Redirect.txt for writing");
                Console.WriteLine(e.Message);
                return;
            }
            Console.SetOut(writer);
            Console.WriteLine(output);
            Console.SetOut(oldOut);
            writer.Close();
            ostrm.Close();

            Console.Write(output);
        }