Beispiel #1
0
 public void ProcessFile(string fileName, IAnalyzer analyzer)
 {
     var sw = Stopwatch.StartNew();
     StreamReader reader;
     if (!TryOpenFile(fileName, out reader))
         return;
     using(reader)
     {
         PrintFileInfo(fileName, reader);
         ProgressNotifier progressNotifier = ProgressNotifier.Start("Reading and analyzing..", reader.BaseStream.Length - reader.BaseStream.Position);
         var chars = new char[4 * 1024];
         int read;
         while((read = reader.Read(chars, 0, chars.Length)) > 0)
         {
             for(int i = 0; i < read; i++)
             {
                 analyzer.TreatChar(chars[i]);
             }
             progressNotifier.ReportCompleted(reader.BaseStream.Position);
         }
         progressNotifier.Finish();
     }
     var analysisResult = analyzer.Finish();
     Console.Out.WriteLine("----");
     Console.Out.WriteLine(analysisResult.ToHumanReadableText());
     Console.Out.WriteLine("----");
     Console.Out.WriteLine("Working time: " + sw.Elapsed);
 }