/// <summary> /// Create a RecordSet by collecting distinct records from given input files /// </summary> /// <param name="inputFiles">Array of input text files</param> public static RecordSet CreateRecordSet(string[] inputFiles) { var recordSet = new RecordSet(); foreach (var file in inputFiles) { try { recordSet.UnionWith(GetRecordsFromFile(file)); } catch (FileNotFoundException e) { // if an input file does not exist, log the exception and continue Console.WriteLine("Exception: {0} {1}", e.Message, e.FileName); } } return(recordSet); }
static void Main(string[] args) { Console.WriteLine("Record Parser Console Application."); var recordSet = RecordSet.CreateRecordSet(new string[] { @"../../App_Data/records1.txt", @"../../App_Data/records2.txt", @"../../App_Data/records3.txt" }); OutputCollection("(0) Original collection of distinct records", recordSet); OutputCollection("(1) Records sorted by Gender, then by Last Name, acending", recordSet.SortByGenderAndThenByLastName()); OutputCollection("(2) Records sorted by Date of Birth, ascending", recordSet.SortByDateOfBirth()); OutputCollection("(3) Records sorted by Last Name, descending", recordSet.SortByLastNameDescending()); Console.ReadKey(); }