Changeset 875 for trunk/tools
- Timestamp:
- 11/30/08 00:40:01 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/ConfigMerger/ConfigMerger.cs
r849 r875 68 68 if (source != null) { 69 69 if (destination == null) { 70 XmlNode clone = document.ImportNode(source, true);71 document.SelectSingleNode(root).AppendChild( clone);70 XmlNode newNode = document.ImportNode(source, true); 71 document.SelectSingleNode(root).AppendChild(newNode); 72 72 } else { 73 73 foreach (XmlNode node in source.ChildNodes) { 74 XmlNode clone = document.ImportNode(node, true); 75 destination.AppendChild(clone); 74 XmlNode newNode = document.ImportNode(node, true); 75 XmlNode oldNode = destination.SelectSingleNode(BuildXPathString(newNode)); 76 if (oldNode != null) 77 destination.ReplaceChild(newNode, oldNode); 78 else 79 destination.AppendChild(newNode); 76 80 } 77 81 } 78 82 } 79 83 } 84 85 private static string BuildXPathString(XmlNode node) { 86 StringBuilder builder = new StringBuilder(); 87 builder.Append(node.Name); 88 if (node.Attributes.Count > 0) { 89 XmlAttribute attrib = node.Attributes[0]; 90 builder.Append("["); 91 builder.Append("@" + attrib.Name + "='" + attrib.Value + "'"); 92 for (int i = 1; i < node.Attributes.Count; i++) { 93 attrib = node.Attributes[i]; 94 builder.Append(" and @" + attrib.Name + "='" + attrib.Value + "'"); 95 } 96 builder.Append("]"); 97 } 98 return builder.ToString(); 99 } 80 100 } 81 101 }
Note: See TracChangeset
for help on using the changeset viewer.