private void MergeInNewFile(string olderFilePath, string newerFilePath, string outputPath) { XmlDocument newerDoc = new XmlDocument(); newerDoc.Load(newerFilePath); XmlWriterSettings settings = new XmlWriterSettings(); settings.NewLineOnAttributes = true; //ugly, but great for merging with revision control systems settings.NewLineChars = "\r\n"; settings.Indent = true; settings.IndentChars = "\t"; settings.CheckCharacters = false; // nb: don't use XmlTextWriter.Create, that's broken. Ignores the indent setting using (XmlWriter writer = XmlWriter.Create(outputPath /*Console.Out*/, settings)) { //For each entry in the new guy, read through the whole base file XmlReaderSettings readerSettings = new XmlReaderSettings(); readerSettings.CheckCharacters = false; //without this, we die if we simply encounter a (properly escaped) other-wise illegal unicode character, e.g.  readerSettings.IgnoreWhitespace = true; //if the reader returns whitespace, the writer ceases to format xml after that point using (XmlReader olderReader = XmlReader.Create(olderFilePath, readerSettings)) { //bool elementWasReplaced = false; while (!olderReader.EOF) { ProcessOlderNode(olderReader, newerDoc, writer); } } } // After writing the updated file, ensure that it ends up sorted correctly. LiftSorter.SortLiftFile(outputPath); }
private void PutFilesInFixedOrder() { LiftSorter.SortLiftFile(_liftPathName); LiftSorter.SortLiftRangesFile(Path.ChangeExtension(_liftPathName, "lift-ranges")); }