private void Fixup(string srcPath, string dstPath) { Message message; var stats = new Statistics(); var classifier = new MessageClassifier(); var translator = new LiveMessageTranslator(); using(var input = File.OpenRead(srcPath)) using(var reader = new DecoratedObjectReader(input)) using(var output = File.Create(dstPath)) using(var writer = new DecoratedObjectWriter(output)) { while(true) { if((message = reader.Read<Message>()) == null) { break; } ++stats.Read; if(classifier.IsTranslated(message)) { ++stats.OrgTranslated; continue; } writer.Write(message); ++stats.Written; if((message = translator.Translate(message)) != null) { if(message is CompositeMessage) { foreach(var component in ((CompositeMessage)message).Messages) { writer.Write(component); ++stats.Written; ++stats.NewTranslated; } } else { writer.Write(message); ++stats.Written; ++stats.NewTranslated; } } } writer.Write(null); } stats.Print(); }