public virtual XmlElement ToXml(IXmlable xmlable) { if (Object.ReferenceEquals(null, xmlable)) { return(null); } String xmlName = null; bool isUnique = false; if (!_xmlFormater.GetTypeXmlInfo(xmlable.GetType(), out xmlName, out isUnique)) { System.Diagnostics.Debug.Assert(false, "could not find the Xmlable information of " + xmlable.GetType().ToString()); return(null); } if (!String.IsNullOrEmpty(xmlName)) { if (isUnique) { String strObjId = null; if (_objToXmlId.TryGetValue(xmlable, out strObjId) && !String.IsNullOrEmpty(strObjId)) { XmlElement ele = this.Document.CreateElement(xmlName); XmlToolkit.SetAttribute(ele, _xmlIdAttr, strObjId); return(ele); } } XmlElement ele2 = this.Document.CreateElement(xmlName); if (isUnique) { String xmlId = Guid.NewGuid().ToString(); _objToXmlId.Add(xmlable, xmlId); _xmlIdToObj.Add(xmlId, xmlable); XmlToolkit.SetAttribute(ele2, _xmlIdAttr, xmlId); } xmlable.ToXml(ele2, this); return(ele2); } return(null); }