/// <summary>Serializes PollProjects object to string</summary> /// <param name="data">to be serialized</param> /// <returns>serialized string or null</returns> private string Serialize(PollProjects data) { try { if (data == null) { return(null); } XmlSerializer xsSubmit = new XmlSerializer(data.GetType()); // set the namespace XmlSerializerNamespaces ns = new XmlSerializerNamespaces(); ns.Add("lp", DEFAULT_NS); string xml = null; using (StringWriter sww = new StringWriter()) using (XmlWriter writer = XmlWriter.Create(sww)) { xsSubmit.Serialize(writer, data, ns); xml = sww.ToString(); } return(xml); } catch (Exception) { throw; } }
public bool Save(PollProjects data) { try { RemoveAll(); _ppt.CustomXMLParts.Add(Serialize(data)); return(true); } catch (Exception) { throw; } }
/// <summary>Desterilizes string to Poll Projects data</summary> /// <param name="data">string to be serialized</param> /// <returns>instance of the PollProjects data or null</returns> private PollProjects Deserialize(string data) { PollProjects retVal = null; if (string.IsNullOrWhiteSpace(data)) { return(retVal); } using (XmlReader reader = XmlReader.Create(new StringReader(data))) { XmlSerializer serializer = new XmlSerializer(typeof(PollProjects)); retVal = (PollProjects)serializer.Deserialize(reader); } return(retVal); }