Esempio n. 1
0
        static void Main(string[] args)
        {
            Console.WriteLine("This program counts the number of found words or expressions in comments from a file C# (*.cs).");

            ILoadService loadService = new LoadService();

            while (true)
            {
                Console.WriteLine("Press any key to select file and count.");
                Console.ReadKey();

                var resultLoad = loadService.LoadFile();
                if (resultLoad.Result)
                {
                    Console.WriteLine();
                    Console.WriteLine("Please enter a word or expression");
                    string searchWord = Console.ReadLine();

                    var expressionService = new ExpressionService();

                    Console.WriteLine(new string ('-', 50));
                    var resultCount = expressionService.CountNumberExpressionsAsync(searchWord, resultLoad.Data).Result;
                    if (resultCount.Result)
                    {
                        Console.WriteLine($"{resultCount.Message} {resultCount.Data}.");
                    }
                    else
                    {
                        Console.WriteLine(resultCount.Message);
                    }
                    Console.WriteLine();
                }
                else
                {
                    Console.WriteLine(resultLoad.Message);
                }

                Console.WriteLine(new string('-', 50));
                Console.WriteLine("Press key 'E' to exit or any key to continue.");
                var key = Console.ReadKey();
                if (key.Key == ConsoleKey.E)
                {
                    break;
                }
                Console.Clear();
            }
        }