Ejemplo n.º 1
0
        public IList <Person> ExtractPeople(IList <string> lines)
        {
            Console.WriteLine("Starting to parse people. ");
            foreach (string line in lines)
            {
                try
                {
                    if (!string.IsNullOrWhiteSpace(line) && !line.StartsWith("#"))
                    {
                        Console.WriteLine("Parsing:");
                        Console.WriteLine(line);

                        IList <string> splitedLine = line.Split(' ')
                                                     .Where(part => !string.IsNullOrWhiteSpace(part))
                                                     .ToList();

                        Person person = _personBuilder.Build(splitedLine);
                        Console.WriteLine(string.Format("People extracted. Name: {0}", person.Name));

                        _listOfPeople.Add(person);
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Error when extracting and parsing data. Press any key to cancel the program.");
                    Console.ReadKey();

                    Environment.Exit(0);
                }
            }

            return(_listOfPeople);
        }
Ejemplo n.º 2
0
        public List <Person> Generate(int count)
        {
            List <Person> people = new List <Person>();

            for (int i = 0; i < count; i++)
            {
                Person person = personBuilder.Build();
                people.Add(person);
            }

            return(people);
        }