Ejemplo n.º 1
0
        /// <summary>
        /// Processes input from the console and invokes the invoker until 'exit' is typed.
        /// </summary>
        public void ProcessInput()
        {
            string line = string.Empty;

            outputter.PrintLine("Zühlke Agile Course [Version 19.1.2010]");
            outputter.PrintLine("(C) Copyright 2006-2010 Rainer Grau and Daniel Tobler.");

            while (line.Trim().Equals("exit", StringComparison.OrdinalIgnoreCase) == false)
            {
                int readChar = 0;
                var input    = new StringBuilder();

                outputter.NewLine();
                outputter.Print(drive.Prompt);
                try
                {
                    while (readChar != '\n')
                    {
                        readChar = System.Console.Read();
                        input.Append((char)readChar);
                    }

                    line = input.ToString();
                }
                catch (IOException)
                {
                    // do nothing by intention
                }

                invoker.ExecuteCommand(line, outputter);
            }

            outputter.PrintLine("\nGoodbye!");
            drive.Save();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// creating a task for the recieved client
        /// </summary>
        /// <param name="client"></param>
        /// <returns></returns>
        public string HandleClient(TcpClient client)
        {
            string result = "";

            new Task(() =>
            {
                using (NetworkStream stream = client.GetStream())
                    using (BinaryReader reader = new BinaryReader(stream))
                        using (BinaryWriter writer = new BinaryWriter(stream))
                        {
                            string commandLine = reader.ReadString();
                            JObject obj        = JsonConvert.DeserializeObject <JObject>(commandLine);
                            try {
                                result = exec.ExecuteCommand(obj["inst"].ToString(), obj["etc"].ToString(), client, writer, reader);
                            }catch (Exception e)
                            {
                                result = exec.ExecuteCommand(obj["inst"].ToString(), null, client, writer, reader);
                            }
                            this.handle?.Invoke(result);
                        }
                client.Close();
            }).Start();
            return(result);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Processes input from the console and invokes the invoker until 'exit' is typed.
        /// </summary>
        public void ProcessInput()
        {
            string line = string.Empty;

            outputter.PrintLine("DOSBox, Scrum.org, Professional Scrum Developer Training");
            outputter.PrintLine("Copyright (c) Rainer Grau and Daniel Tobler. All rights reserved.");

            while (line.Trim().Equals("exit", StringComparison.OrdinalIgnoreCase) == false)
            {
                int readChar = 0;
                var input    = new StringBuilder();

                outputter.NewLine();
                outputter.Print(drive.Prompt);
                try
                {
                    while (readChar != '\n')
                    {
                        readChar = System.Console.Read();
                        input.Append((char)readChar);
                    }

                    line = input.ToString();
                }
                catch (IOException)
                {
                    // do nothing by intention
                }

                outputter.ResetStatistics();
                invoker.ExecuteCommand(line, outputter);
            }

            outputter.PrintLine("\nGoodbye!");
            drive.Save();
        }