예제 #1
0
        static async Task <int> Main(string[] args)
        {
            var reader = new TxtFileReader("dataStorage.txt");

            var fileAccessor = new TxtFileDataAccess <User>(reader);

            var users = await fileAccessor.LoadDataAsync();

            Console.WriteLine(String.Join(Environment.NewLine, users));

            return(0);
        }
        private void btnRead_Click(object sender, EventArgs e)
        {
            TxtFileReader reader = new TxtFileReader(this.tbxFilePath.Text);

            try
            {
                reader.Open();
                List <string> list = reader.FromStartReadLine((int)this.numStart.Value, (int)this.numEnd.Value);
                this.tbxReadResult.Text = "";
                foreach (var s in list)
                {
                    this.tbxReadResult.AppendText(s);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "读取异常");
            }
            finally
            {
                reader.Close();
            }
        }
예제 #3
0
        private static void ProcessSearchResults(string pathToTxtFile)
        {
            var index      = pathToTxtFile.LastIndexOf('/');
            var nameOfFile = pathToTxtFile.Substring(index, pathToTxtFile.Length - (pathToTxtFile.Length - index - 1));

            Speak("Reading phones.txt and extracting people");
            var people = TxtFileReader.ExtractPeople(pathToTxtFile);

            Speak("Now I'm extracting the commands from the file");
            var commands = TxtFileReader.ExtractCommands(pathToTxtFile);

            foreach (var command in commands)
            {
                string townSearchParam = string.Empty;
                if (command.Town != null)
                {
                    townSearchParam += ", in town: " + command.Town;
                }

                Speak("Searching for : " + command.NameToSeachFor + townSearchParam);
                Speak(Searcher.Search(command, people));
            }
        }
예제 #4
0
 public void SetUp()
 {
     reader = new TxtFileReader();
 }
예제 #5
0
        public static void Main(string[] args)
        {
            for (; ;)
            {
                int           option;
                Ordering      order     = new Ordering();
                SpecTimeOrder specOrder = new SpecTimeOrder();

                Console.WriteLine("Hello my friend! Here is available menu: \n 1 - Borsch, \n 2 – Green Borsch, \n 3 – Vegetable Soup, \n 4 - Strawberry Jelly, \n 5 - Banana Juice \n At 20:30 our restaraunt has SPECIAL Fresh Menu, \n 7 - Choose text menu: ");

                option = Convert.ToInt32(Console.ReadLine());


                if (option == 1)
                {
                    try
                    {
                        specOrder.SpecTime();
                        order.MakeOrder(Dish.dishName.Borsch);
                        Console.WriteLine("Your order is cooking!");
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message);
                    }
                }
                else if (option == 2)
                {
                    try
                    {
                        specOrder.SpecTime();
                        order.MakeOrder(Dish.dishName.Green_Borsch);
                        Console.WriteLine("Your order is cooking!");
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message);
                    }
                }
                else if (option == 3)
                {
                    try
                    {
                        specOrder.SpecTime();
                        order.MakeOrder(Dish.dishName.Vegetable_Soup);
                        Console.WriteLine("Your order is cooking!");
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message);
                    }
                }
                else if (option == 4)
                {
                    try
                    {
                        specOrder.SpecTime();
                        order.MakeOrder(Dish.dishName.Strawberry_Jelly);
                        Console.WriteLine("Your order is cooking!");
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message);
                    }
                }
                else if (option == 5)
                {
                    try
                    {
                        specOrder.SpecTime();
                        order.MakeOrder(Dish.dishName.Banana_Juice);
                        Console.WriteLine("Your order is cooking!");
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message);
                    }
                }
                else if (option == 7)
                {
                    TxtFileReader.TxtReader();
                }
                else if (option == 6)
                {
                    break;
                }
            }
            Console.WriteLine("The end of choosing");
        }