예제 #1
0
        public void Run()
        {
            string input;

            while ((input = reader.ReadLine()) != "Exit")
            {
                var args = input.Split(" ", StringSplitOptions.RemoveEmptyEntries);

                using (var context = new BillsPaymentSystemContext())
                {
                    string result;

                    try
                    {
                        result = commandInterpreter.Read(args, context);
                    }
                    catch (InvalidOperationException ex)
                    {
                        result = "ERROR: " + ex.Message;
                    }
                    catch (Exception ex)
                    {
                        result = "ERROR: " + ex.Message;
                    }

                    writer.WriteLine(result);
                }
            }
        }
        public void Run()
        {
            IDatabaseInitializerService initializeService =
                this.serviceProvider.GetService <IDatabaseInitializerService>();

            initializeService.InitializeDatabase();

            ICommandInterpreter commandInterpreter = this.serviceProvider.GetService <ICommandInterpreter>();

            while (true)
            {
                try
                {
                    Console.WriteLine("Enter command:");

                    string[] input = Console.ReadLine().Split(" ", StringSplitOptions.RemoveEmptyEntries);

                    string result = commandInterpreter.Read(input);

                    Console.WriteLine(result);
                    Console.WriteLine();
                }
                catch (Exception exception) when(exception is SqlException || exception is ArgumentException ||
                                                 exception is InvalidOperationException)
                {
                    Console.WriteLine(exception.Message);
                    Console.WriteLine();
                }
            }
        }
예제 #3
0
        public void Run()
        {
            string input = Console.ReadLine();

            while (input != "End")
            {
                try
                {
                    string[] inputArgs = input.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);


                    string result = commandInterpreter.Read(animalCentre, inputArgs);

                    Console.WriteLine(result);
                }
                catch (TargetInvocationException tie)
                {
                    Console.WriteLine($"{tie.InnerException.InnerException.GetType().Name}: " + tie.InnerException.InnerException.Message);
                }

                input = Console.ReadLine();
            }

            string adoptedAnimals = animalCentre.AllAdoptedAnimals();

            Console.WriteLine(adoptedAnimals);
        }
예제 #4
0
 public void Run()
 {
     Console.WriteLine(AvailableCommands());
     while (true)
     {
         try
         {
             Console.Write("Enter new command: ");
             string[] args = Console.ReadLine().Split(" ", StringSplitOptions.RemoveEmptyEntries);
             if (args[0] == "Exit")
             {
                 break;
             }
             using (BillsPaymentSystemContext context = new BillsPaymentSystemContext())
             {
                 string result = commandInterpreter.Read(args, context);
                 Console.WriteLine(result);
             }
         }
         catch (ArgumentException ae)
         {
             Console.WriteLine(ae.Message);
         }
     }
 }
        public void Run()
        {
            IDatabaseService databaseInitializer = this.serviceProvider.GetService <IDatabaseService>();

            databaseInitializer.Initialize();

            ICommandInterpreter commandInterpreter = this.serviceProvider.GetService <ICommandInterpreter>();
            IReader             reader             = this.serviceProvider.GetService <IReader>();
            IWriter             writer             = this.serviceProvider.GetService <IWriter>();

            while (true)
            {
                string[] inputArgs = reader.ReadLine().Split(" ", StringSplitOptions.RemoveEmptyEntries);

                try
                {
                    string result = commandInterpreter.Read(inputArgs, this.serviceProvider);
                    writer.WriteLine(result);
                }
                catch (ArgumentNullException ane)
                {
                    writer.WriteLine(ane.Message);
                }
                catch (ArgumentException ae)
                {
                    writer.WriteLine(ae.Message);
                }
            }
        }
예제 #6
0
 public void Run()
 {
     while (true)
     {
         Console.WriteLine(commandInterpreter.Read(Console.ReadLine()));
     }
 }
예제 #7
0
 public void Run()
 {
     while (true)
     {
         string input = Console.ReadLine();
         Console.WriteLine(commandInterpreter.Read(input));
     }
 }
예제 #8
0
 public void Run()
 {
     while (true)
     {
         var input  = Console.ReadLine();
         var result = commandInterpreter.Read(input);
         Console.WriteLine(result);
     }
 }
 public void Run()
 {
     while (true)
     {
         string command = Console.ReadLine();
         string result  = commandInterpreter.Read(command);
         Console.WriteLine(result);
     }
 }
예제 #10
0
파일: Engine.cs 프로젝트: mila89/OOP
 public void Run()
 {
     while (true)
     {
         string input  = Console.ReadLine();
         var    result = _command.Read(input);
         Console.WriteLine(result);
     }
 }
예제 #11
0
        public void Run()
        {
            while (true)
            {
                string input = Console.ReadLine();

                string result = _commandInterpretator.Read(input);
                Console.WriteLine(result);
            }
        }
예제 #12
0
        public void Run()
        {
            string input;

            while ((input = Console.ReadLine()) != "Exit")
            {
                string result = commandInterpreter.Read(input);
                Console.WriteLine(result);
            }
        }
예제 #13
0
        public void Run()
        {
            string line = Console.ReadLine();

            while (true)
            {
                Console.WriteLine(commandInterpreter.Read(line));

                line = Console.ReadLine();
            }
        }
예제 #14
0
        public void Run()
        {
            while (true)
            {
                string input = Console.ReadLine();

                string output = command.Read(input);

                Console.WriteLine(output);
            }
        }
예제 #15
0
        public void Run()
        {
            int userId = int.Parse(Console.ReadLine());

            using (BillsPaymentSystemContext context = new BillsPaymentSystemContext())
            {
                string result = commandInterpreter.Read(userId, context);
            }

            //TODO: Add catch exceptions
        }
        public void Run()
        {
            string input = "";

            while ((input = Console.ReadLine()) != "Exit")
            {
                string[]            commandParams      = input.Split();
                ICommandInterpreter commandInterpreter = provider.GetService <ICommandInterpreter>();
                string result = commandInterpreter.Read(commandParams);
                Console.WriteLine(result);
            }
        }
예제 #17
0
 public void Run()
 {
     while (true)
     {
         //read data from console
         string input = Console.ReadLine();
         //pass it to proper CommandInterpreter and receive it
         var result = commandInterpreter.Read(input);
         //print output data
         Console.WriteLine(result);
     }
 }
예제 #18
0
 public void Run()
 {
     while (true)
     {
         string input  = Console.ReadLine();
         string result = commandInterpreter.Read(input);
         if (result == null)
         {
             break;
         }
         Console.WriteLine(result);
     }
 }
예제 #19
0
        public void Run()
        {
            //TODO: Try catch blocks
            while (true)
            {
                string[] inputParams = Console.ReadLine()
                                       .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)
                                       .ToArray();

                ICommandInterpreter commandInterpreter = this.serviceProvider.GetService <ICommandInterpreter>();
                string result = commandInterpreter.Read(inputParams);
                Console.WriteLine(result);
            }
        }
예제 #20
0
        public void Run()
        {
            string args = Console.ReadLine();

            try
            {
                string result = commandInterpreter.Read(args);
                Console.WriteLine(result);
            }
            catch (ArgumentException ae)
            {
                Console.WriteLine(ae.Message);
            }
        }
예제 #21
0
        public void Run()
        {
            IDbInitializerService initialzeDb = this.serviceProvider.GetService <IDbInitializerService>();

            initialzeDb.InitializeDatabase();

            ICommandInterpreter commandInterpreter = this.serviceProvider.GetService <ICommandInterpreter>();

            while (true)
            {
                string[] input  = Console.ReadLine().Split(" ", StringSplitOptions.RemoveEmptyEntries);
                string   result = commandInterpreter.Read(input);
                Console.WriteLine(result);
            }
        }
예제 #22
0
파일: Engine.cs 프로젝트: o-todorov/SoftUni
        public void Run()
        {
            while (true)
            {
                string commandInput  = Console.ReadLine();
                string commandResult = command.Read(commandInput);

                if (commandResult == null)
                {
                    return;
                }

                Console.WriteLine(commandResult);
            }
        }
예제 #23
0
 public void Run()
 {
     while (true)
     {
         try
         {
             string output = commandInterpreter.Read(Console.ReadLine());
             Console.WriteLine(output);
         }
         catch (Exception ae)
         {
             Console.WriteLine(ae.Message);
         }
     }
 }
예제 #24
0
        public void Run()
        {
            while (true)
            {
                string input = Console.ReadLine();

                string output = command.Read(input);

                Console.WriteLine(output);
            }

            HelloCommand hc = new HelloCommand();

            Console.WriteLine(hc.GetType().FullName);
        }
예제 #25
0
파일: Engine.cs 프로젝트: ZohanBG/SoftUni
        public void Run()
        {
            while (true)
            {
                string line = Console.ReadLine();

                string result = command.Read(line);

                if (result == null)
                {
                    break;
                }
                Console.WriteLine(result);
            }
        }
예제 #26
0
        public void Run()
        {
            string input = Console.ReadLine();

            while (true)
            {
                string result = commandInterpreter.Read(input);
                if (result == null)
                {
                    Environment.Exit(1);
                }
                Console.WriteLine(result);
                input = Console.ReadLine();
            }
        }
예제 #27
0
        public void Run()
        {
            while (true)
            {
                var inputArgs = Console.ReadLine()
                                .Split(" ", StringSplitOptions.RemoveEmptyEntries)
                                .ToArray();

                using (BookShopContext context = new BookShopContext())
                {
                    var result = commandInterpreter.Read(inputArgs, context);

                    Console.WriteLine(result);
                }
            }
        }
예제 #28
0
        public void Run()
        {
            string input;

            while ((input = Console.ReadLine()) != string.Empty)
            {
                var inputParams = input.Split(" ", StringSplitOptions.RemoveEmptyEntries);
                using (var context = new BillsPaymentSystemContext())
                {
                    var result = _commandInterpreter.Read(inputParams, context);
                    Console.WriteLine(result);
                }

                //TODO
            }
        }
예제 #29
0
파일: Engine.cs 프로젝트: MartiHr/Softuni
        public void Run()
        {
            string command = string.Empty;

            while ((command = Console.ReadLine()) != "Exit")
            {
                string result = commandInterpreter.Read(command);

                if (result == null)
                {
                    break;
                }

                Console.WriteLine(result);
            }
        }
예제 #30
0
        public void Run()
        {
            while (true)
            {
                try
                {
                    var commandRead   = Console.ReadLine();
                    var commandResult = commandInterpreter.Read(commandRead);

                    Console.WriteLine(commandResult);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                }
            }
        }