Beispiel #1
0
 public static IEnumerable <string> SumRecords(
     DataSource dataSource,
     ISumFormatter formatter)
 {
     return(dataSource.ReadIntRecords(16)
            .Select(args => formatter.Format(args, args.Sum())));
 }
Beispiel #2
0
 public void ProcessOld()
 {
     using (var input = openDatasource())
         using (var writer = new StreamWriter(outputFilename))
         {
             var c = 0;
             while (true)
             {
                 string[] record = input.NextRecord();
                 if (record == null)
                 {
                     break;
                 }
                 c++;
                 var nums = record.Select(part => Convert.ToInt32(part, 16)).ToArray();
                 var sum  = nums.Sum();
                 var text = formatter.Format(nums, sum);
                 writer.WriteLine(text);
                 if (c % 100 == 0)
                 {
                     Console.WriteLine("processed {0} items", c);
                 }
             }
         }
 }