예제 #1
0
        static void ReadFromFIle_WriteToFile()//ToDo
        {
            FileOperator fileOperator = new FileOperator();

            fileOperator.TryToFindSourceFile();
            if (fileOperator.IsBreakOperation)
            {
                return;
            }
            fileOperator.TryToGetResultFile();
            if (fileOperator.IsBreakOperation)
            {
                return;
            }

            StreamReader streamReader = new StreamReader(fileOperator.SourceFileAddress);

            while (!streamReader.EndOfStream)
            {
                var parser = new Parser();
                parser.TryToConvert(streamReader.ReadLine());
                if (!parser.IsParseSuccessful)
                {
                    continue;
                }
                Point point = new Point(parser.Result[0], parser.Result[1]);
                point.PrintCordinateToFile(fileOperator.ResultFileAddress);
            }
            streamReader.Close();
        }
예제 #2
0
        static void ReadFromFIle_WriteToConsole()//ToDo
        {
            FileOperator fileOperator = new FileOperator();

            fileOperator.TryToFindSourceFile();
            if (fileOperator.IsBreakOperation)
            {
                return;
            }

            string nextString;

            using (var f = new StreamReader(fileOperator.SourceFileAddress))
            {
                while ((nextString = f.ReadLine()) != null)
                {
                    var parser = new Parser();
                    parser.TryToConvert(nextString);
                    if (!parser.IsParseSuccessful)
                    {
                        Console.ForegroundColor = ConsoleColor.Red;
                        Console.WriteLine(parser.ExceptionMessage);
                        Console.ForegroundColor = ConsoleColor.White;
                        continue;
                    }
                    Point point = new Point(parser.Result[0], parser.Result[1]);
                    point.PrintCordinateToConsole();
                }
            }
        }
예제 #3
0
        static void ManualInput_WriteToFile()//finish
        {
            FileOperator fileOperator = new FileOperator();

            fileOperator.TryToGetResultFile();
            if (fileOperator.IsBreakOperation)
            {
                return;
            }

            while (true)
            {
                Console.ForegroundColor = ConsoleColor.Yellow;
                Console.WriteLine("Введите данные или @ для выхода в меню");
                Console.ForegroundColor = ConsoleColor.White;
                Console.Write("> ");
                string sourceData = Console.ReadLine();
                if (sourceData == "@")
                {
                    break;
                }
                if (sourceData == "")
                {
                    continue;
                }

                var parser = new Parser();
                parser.TryToConvert(sourceData);
                if (!parser.IsParseSuccessful)
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine(parser.ExceptionMessage);
                    Console.ForegroundColor = ConsoleColor.White;
                    continue;
                }
                Point point = new Point(parser.Result[0], parser.Result[1]);
                point.PrintCordinateToFile(fileOperator.ResultFileAddress);
            }
        }