/// <summary> /// /// </summary> /// <returns></returns> private static void FillDictionary(IDictionary <string, string> map, XDiffItem diff) { var id = diff.BasisElement.Attribute("id"); var code = diff.BasisElement.Attribute("code"); var oldname = diff.BasisElement.Name.LocalName; if (diff.Action == XDiffAction.RenameElement) { var newname = diff.NewValue; if (null != id) { map[oldname + "-id-" + id.Value] = newname + "-id-" + id.Value; } if (null != code) { map[oldname + "-code-" + code.Value] = newname + "-code-" + code.Value; } } else if (diff.Action == XDiffAction.ChangeAttribute) { if (diff.NewestAttribute.Name.LocalName == "code") { map[oldname + "-code-" + code.Value] = oldname + "-code-" + diff.NewestAttribute.Value; map["code-" + code.Value] = "code-" + diff.NewestAttribute.Value; } else if (diff.NewestAttribute.Name.LocalName == "id") { map[oldname + "-id-" + id.Value] = oldname + "-id-" + diff.NewestAttribute.Value; map["id-" + id.Value] = "id-" + diff.NewestAttribute.Value; } } }
private static XDiffItem CreateNew(XDiffMatch xd) { var newest = new XElement(xd.ns.First()); foreach (XElement source in xd.ns.Skip(1)) { foreach (XAttribute attribute in source.Attributes()) { if (attribute.Name.LocalName.StartsWith("set-")) { newest.SetAttributeValue(attribute.Name.LocalName.Substring(4), attribute.Value); } else { newest.SetAttributeValue(attribute.Name, attribute.Value); } } if (!string.IsNullOrWhiteSpace(source.Value)) { newest.Value = source.Value; } } var item = new XDiffItem { Action = XDiffAction.CreateElement, NewestElement = newest }; return(item); }