public bool Save(PollProjects data) { try { RemoveAll(); _ppt.CustomXMLParts.Add(Serialize(data)); return true; } catch (Exception) { throw; } }
/// <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; } }