private string GetExportIds(string value) { Dictionary <string, string> replacements = new Dictionary <string, string>(); foreach (Match m in Regex.Matches(value, @"\d{1,9}")) { int id; if (int.TryParse(m.Value, out id)) { Guid?localGuid = GetGuidFromId(id); if (localGuid != null) { if (!replacements.ContainsKey(m.Value)) { Guid sourceGuid = NodeIdMapper.GetSourceGuid(localGuid.Value); replacements.Add(m.Value, sourceGuid.ToString()); } } } } foreach (KeyValuePair <string, string> pair in replacements) { value = value.Replace(pair.Key, pair.Value); } return(value); }
public XElement uSyncIContentExportBase(IContentBase item, string type) { var node = new XElement(type); Guid sourceGuid = NodeIdMapper.GetSourceGuid(item.Key); node.Add(new XAttribute("guid", sourceGuid)); node.Add(new XAttribute("id", item.Id)); node.Add(new XAttribute("nodeName", item.Name)); node.Add(new XAttribute("isDoc", "")); node.Add(new XAttribute("updated", item.UpdateDate)); foreach (var prop in item.Properties.Where(p => p != null)) { XElement propNode = null; try { propNode = prop.ToXml(); } // sometime you can't serialize the property catch { propNode = new XElement(prop.Alias, prop.Value); } string xml = ""; xml = GetExportIds(GetInnerXML(propNode)); var updatedNode = XElement.Parse( String.Format("<{0}>{1}</{0}>", propNode.Name.ToString(), xml), LoadOptions.PreserveWhitespace); node.Add(updatedNode); } return(node); }