public void AddContent(DocXML xml) { Index.IncludedDocs.Add(new IndexDocXML() { Name = xml.Name, UUID = xml.UUID, hasEnglish = !xml.Coptic, hasCoptic = xml.Coptic, hasArabic = false }); }
/// <summary> /// Serializes and save a DocXML file /// </summary> /// <param name="filename">Path to save to, including filename</param> /// <param name="content">List of stanzas to save</param> /// <param name="coptic">If the input language is Coptic</param> /// <param name="name">Name of the reading or hymn</param> /// <returns></returns> public static bool SaveDocXML(string filename, IEnumerable <string> content, bool coptic, string name) { try { // Create an instance of the XmlSerializer class; // specify the type of object to serialize. XmlSerializer serializer = new XmlSerializer(typeof(DocXML)); TextWriter writer = new StreamWriter(filename); DocXML SaveX = new DocXML(); SaveX.Coptic = coptic; SaveX.Stanzas = new List <DocXML.StanzaXML>(); if (coptic) { foreach (string s in content) { SaveX.Stanzas.Add(new DocXML.StanzaXML(s, "coptic")); } } else { foreach (string s in content) { // Replaces c# escaped new lines with XML new lines SaveX.Stanzas.Add(new DocXML.StanzaXML(s.Replace("\r\n", "
"), "english")); } } // Checks if first stanza is empty if (SaveX.Stanzas[0].Content == "") { SaveX.Stanzas.RemoveAt(0); } SaveX.Name = name; // Serialize the save file, and close the TextWriter. serializer.Serialize(writer, SaveX); writer.Close(); return(true); } catch { return(false); } }