コード例 #1
0
ファイル: Program.cs プロジェクト: XGio83/lm_interview
        private static void Run()
        {
            try
            {
                var puppeteer = new Puppeteer(_diContainer.Resolve <IRobot>(), (r) => { System.Console.WriteLine(r); });
                if (!string.IsNullOrWhiteSpace(_opts.File))
                {
                    //versione batch
                    if (File.Exists(_opts.File))
                    {
                        var commands = File.ReadAllLines(_opts.File);
                        puppeteer.EnqueueCommands(commands.ToList());
                        puppeteer.ExecuteQueue();
                    }
                    else
                    {
                        System.Console.WriteLine("The file provided does not exists");
                    }
                }
                else
                {
                    System.Console.WriteLine("Getting started with your Toy Robot, please write commands:");
                    var command = string.Empty;
                    do
                    {
                        command = System.Console.ReadLine();
                        puppeteer.ExecuteCommand(command);
                    } while (command != "EXIT");
                }
            }
            catch (Exception ex)
            {
                System.Console.WriteLine("Ops.. an error has occured");
            }

            System.Console.ReadLine();
        }