public static bool Serialize(XmlTextWriter writer, IScrScriptureNote ann, string languageInFocus) { if (writer == null || ann == null) { return(false); } try { FdoCache cache = ann.Cache; ILgWritingSystemFactory lgwsf = cache.LanguageWritingSystemFactoryAccessor; XmlScrNote xmlNote = new XmlScrNote(ann, cache.DefaultAnalWs, lgwsf); if (!string.IsNullOrEmpty(xmlNote.Type)) { if (!string.IsNullOrEmpty(languageInFocus)) { xmlNote.LanguageInFocus = languageInFocus; } xmlNote.m_serializingForOxes = true; return(XmlSerializationHelper.SerializeDataAndWriteAsNode(writer, xmlNote)); } } catch { // TODO: Report something useful. } return(false); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Deserializes the oxes annotation node. /// </summary> /// <param name="node">The node.</param> /// <param name="scr">The scripture.</param> /// <param name="styleSheet">The style sheet.</param> /// <returns>The deserialized annotation</returns> /// ------------------------------------------------------------------------------------ public static IScrScriptureNote Deserialize(XmlNode node, IScripture scr, FwStyleSheet styleSheet) { XmlScrNote xmlAnn = XmlSerializationHelper.DeserializeFromString <XmlScrNote>(node.OuterXml, true); return(xmlAnn.WriteToCache(scr, styleSheet)); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Serializes the specified annotation and writes it to the specified XML writer. /// </summary> /// ------------------------------------------------------------------------------------ public static bool Serialize(XmlTextWriter writer, IScrScriptureNote ann, string languageInFocus) { if (writer == null || ann == null) return false; try { FdoCache cache = ann.Cache; ILgWritingSystemFactory lgwsf = cache.LanguageWritingSystemFactoryAccessor; XmlScrNote xmlNote = new XmlScrNote(ann, cache.DefaultAnalWs, lgwsf); if (!string.IsNullOrEmpty(xmlNote.Type)) { if (!string.IsNullOrEmpty(languageInFocus)) xmlNote.LanguageInFocus = languageInFocus; xmlNote.m_serializingForOxes = true; return XmlSerializationHelper.SerializeDataAndWriteAsNode(writer, xmlNote); } } catch { // TODO: Report something useful. } return false; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Creates a new XmlScrNote and initializes some fields that the deserializer would /// initialize. /// </summary> /// <returns>The new XmlScrNote</returns> /// ------------------------------------------------------------------------------------ private XmlScrNote CreateNote() { XmlScrNote ann = new XmlScrNote(); ann.Categories = new List<XmlNoteCategory>(); ann.Discussion = new List<XmlNotePara>(); ann.Resolution = new List<XmlNotePara>(); ann.Suggestion = new List<XmlNotePara>(); ann.Responses = new List<XmlNoteResponse>(); ann.Quote = new List<XmlNotePara>(); return ann; }