Пример #1
0
        private static void CreateTActionPublisher(string sourceName, TraverserException e, ConsolePublisher pub)
        {
            var lines = (e.Cause as IHasLines ?? Traversal.AncestorOfType <IHasLines>(e.Cause as IContained))?.Lines;

            if (lines != null)
            {
                pub.DescriptionReasonLocation(
                    ReportGenre.Traversal,
                    $"{e.Message} Output may contain unexpected results.",
                    StringUtils.LocationString(lines.FirstOrDefault().Number, lines.LastOrDefault().Number, sourceName));
            }
            else
            {
                pub.DescriptionReason(ReportGenre.Traversal, $"{e.Message} Output may contain unexpected results.");
            }
        }
Пример #2
0
        private static void PeselValidationChoice()
        {
            int    licznik = 0;
            string p;

            //tworzenie listy numerów PESEL
            List <string> pesels = new List <string>();

            do
            {
                Console.WriteLine();
                Console.WriteLine();
                Console.WriteLine("Proszę, podaj " + (licznik + 1) + " numer PESEL lub STOP aby zakończyć:");
                p = Console.ReadLine();
                if (String.Compare(p, "stop", true) != 0)
                {
                    pesels.Add(p);
                }
                licznik++;
            }while (String.Compare(p, "stop", true) != 0);

            //tworzenie listy wyników "walidacji"
            List <PeselValidationResult> peselValidations = new List <PeselValidationResult>();

            for (int i = 0; i < pesels.Count; i++)
            {
                PeselValidator        validator       = new PeselValidator(pesels[i]);
                PeselValidationResult peselValidation = validator.SprawdzPesel();

                peselValidations.Add(peselValidation);
            }

            //agregacja danych z listy z rezultatami walidacji... zliczanie błędnych i wyświetlanie błędnych oraz zawartości listy
            bool choiceReportParsed;
            int  choiceReport;

            do
            {
                Console.Clear();
                Console.WriteLine("Wybierz typ raportu: (1) na konsolę, (2) do pliku TXT");
                Console.WriteLine();
                var choiceReportKey = Console.ReadKey();

                choiceReportParsed = int.TryParse(choiceReportKey.KeyChar.ToString(), out choiceReport);
            }while (!choiceReportParsed);

            IPublisher publisher = null;

            switch (choiceReport)
            {
            case 1:
                publisher = new ConsolePublisher();
                break;

            case 2:
                publisher = new FilePublisher();
                break;

            default:
                publisher = new PublisherKtoryNicNieRobieZebySieNieWysypalo();
                break;
            }

            Generator generator           = new Generator();
            Reporter  validationsReporter = new Reporter(generator, new IPublisher[] { publisher });

            validationsReporter.Report(peselValidations);

            Console.ReadKey();
        }
Пример #3
0
 private static void CreatePActionPublisher(string sourceName, ConsolePublisher pub, ParserException e)
 {
     pub.DescriptionReasonLocation(ReportGenre.Parsing, $"{e.Message} Output may contain unexpected results.", StringUtils.LocationString(e.StartLine, e.EndLine, sourceName));
 }