/// <summary> /// Loops through all data from files, sorts them and prints them to the console. /// </summary> private void ProcessFiles() { var records = _recordParser.ParseFiles(_fileNames); foreach (var record in _recordSorter.SortRecords(records, _sortCriteria)) { Console.WriteLine($"{record.LastName}, {record.FirstName}, {record.Gender}, {record.FavoriteColor}, {record.BirthDate:M/d/yyy}"); } }
/// <summary> /// Gets records from the "database" and sorts by the given criteria /// </summary> /// <param name="sortCriteria">Sort conditions</param> /// <returns> /// The sorted list of records /// </returns> public IEnumerable <Record> GetRecords(SortCriteria sortCriteria) { // Copy list so lock isn't held during the sort operation. // Lock wouldn't be necessary if there was an actual database. // List <Record> copy; lock (_lockHandle) { copy = _records.ToList(); } return(_recordSorter.SortRecords(_records.ToList(), sortCriteria)); }