static public object Xml2Object(XmlDocument xmlDoc, Type type, bool isXmlFormatterContract) { BaseXmlTransfer xmlTransfer = GetXmlTransfer(isXmlFormatterContract); return(xmlTransfer.ToObject(xmlDoc, type)); //return Deserialize(xmlDoc, type, isXmlFormatterContract); }
/// <summary> /// /// </summary> /// <param name="xml"></param> /// <param name="type"></param> /// <param name="isXmlFormatterContract">true:XmlSerializer , false:DataContractSerializer </param> /// <returns></returns> static public object Xml2Object(string xml, Type type, bool isXmlFormatterContract) { if (string.IsNullOrEmpty(xml)) { return(null); } BaseXmlTransfer transfer = GetXmlTransfer(isXmlFormatterContract); return(transfer.ToObject(xml, type)); /* * XmlDocument xmlDoc = new XmlDocument(); * xmlDoc.LoadXml(xml); * return Xml2Object(xmlDoc, type, isXmlFormatterContract); */ }
static public XmlDocument Object2Xml(object it, Type type, bool isXmlFormatterContract) { BaseXmlTransfer xmlTransfer = GetXmlTransfer(isXmlFormatterContract); return(xmlTransfer.ToXmlDocument(it, type)); /* * using (MemoryStream ms = new MemoryStream()) * { * Serialize(it, type, ms, isXmlFormatterContract); * ms.Position = 0; * XmlTextReader xReader = new XmlTextReader(ms); * XmlDocument xmlDoc = new XmlDocument(); * xmlDoc.Load(xReader); * return xmlDoc; * } */ }