Changeset 2602 for trunk/tools/ConfigMerger
- Timestamp:
- 01/05/10 17:26:13 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/ConfigMerger/ConfigMerger.cs
r1142 r2602 33 33 } 34 34 catch (Exception ex) { 35 Console.Out.WriteLine( ex.Message);35 Console.Out.WriteLine(BuildErrorMessage(ex)); 36 36 } 37 37 } … … 86 86 87 87 private static void Merge(XmlNode source, XmlNode destination, XmlDocument document, string root) { 88 if (source != null) { 89 if (destination == null) { 90 XmlNode newNode = document.ImportNode(source, true); 91 document.SelectSingleNode(root).AppendChild(newNode); 92 } else { 93 foreach (XmlNode node in source.ChildNodes) { 94 XmlNode newNode = document.ImportNode(node, true); 95 XmlNode oldNode = destination.SelectSingleNode(BuildXPathString(newNode)); 96 if (oldNode != null) 97 destination.ReplaceChild(newNode, oldNode); 98 else 99 destination.AppendChild(newNode); 88 try { 89 if (source != null) { 90 if (destination == null) { 91 XmlNode newNode = document.ImportNode(source, true); 92 document.SelectSingleNode(root).AppendChild(newNode); 93 } else { 94 foreach (XmlNode node in source.ChildNodes) { 95 XmlNode newNode = document.ImportNode(node, true); 96 XmlNode oldNode = destination.SelectSingleNode(BuildXPathString(newNode)); 97 if (oldNode != null) 98 destination.ReplaceChild(newNode, oldNode); 99 else 100 destination.AppendChild(newNode); 101 } 100 102 } 101 103 } 104 } 105 catch (Exception ex) { 106 StringBuilder sb = new StringBuilder(); 107 sb.Append("Error while merging node \"").Append(source.Name).Append("\""); 108 throw new Exception(sb.ToString(), ex); 102 109 } 103 110 } … … 118 125 return builder.ToString(); 119 126 } 127 128 private static string BuildErrorMessage(Exception ex) { 129 StringBuilder sb = new StringBuilder(); 130 sb.Append("\n\n"); 131 sb.Append("### ConfigMerger ERROR ###########################################\n" + ex.Message + "\n" + ex.StackTrace + "\n"); 132 while (ex.InnerException != null) { 133 ex = ex.InnerException; 134 sb.Append("-----\n" + ex.Message + "\n" + ex.StackTrace + "\n"); 135 } 136 sb.Append("##################################################################\n\n"); 137 return sb.ToString(); 138 } 120 139 } 121 140 }
Note: See TracChangeset
for help on using the changeset viewer.