private void WriteMultiTextNoWrapper(string propertyName, MultiText text) // review cp see WriteEmbeddedXmlCollection { if (!MultiTextBase.IsEmpty(text)) { AddMultitextForms(propertyName, text); } }
private void WriteCustomMultiTextField(string type, MultiText text) // review cp see WriteEmbeddedXmlCollection { if (!MultiTextBase.IsEmpty(text)) { Writer.WriteStartElement("field"); Writer.WriteAttributeString("type", type); WriteMultiTextNoWrapper(type, text); Writer.WriteEndElement(); } }
public void Add(LexExampleSentence example) { if (!ShouldOutputProperty(LexExampleSentence.WellKnownProperties.ExampleSentence)) { return; } List <string> propertiesAlreadyOutput = new List <string>(); Writer.WriteStartElement("example"); OptionRef source = example.GetProperty <OptionRef>(LexExampleSentence.WellKnownProperties.Source); if (source != null && source.Value.Length > 0) { if (ShouldOutputProperty(LexExampleSentence.WellKnownProperties.Source)) { Writer.WriteAttributeString("source", source.Value); propertiesAlreadyOutput.Add("source"); } } WriteMultiTextNoWrapper(LexExampleSentence.WellKnownProperties.ExampleSentence, example.Sentence); propertiesAlreadyOutput.Add(LexExampleSentence.WellKnownProperties.ExampleSentence); // WriteMultiWithWrapperIfNonEmpty(LexExampleSentence.WellKnownProperties.Translation, "translation", example.Translation); if (!MultiTextBase.IsEmpty(example.Translation)) { Writer.WriteStartElement("translation"); if (!string.IsNullOrEmpty(example.TranslationType)) { Writer.WriteAttributeString("type", example.TranslationType); propertiesAlreadyOutput.Add("type"); } AddMultitextForms(LexExampleSentence.WellKnownProperties.Translation, example.Translation); Writer.WriteEndElement(); propertiesAlreadyOutput.Add(LexExampleSentence.WellKnownProperties.Translation); } if (ShouldOutputProperty(LexExampleSentence.WellKnownProperties.ExampleSentence)) { WriteWellKnownCustomMultiText(example, PalasoDataObject.WellKnownProperties.Note, propertiesAlreadyOutput); } WriteCustomProperties(example, propertiesAlreadyOutput); Writer.WriteEndElement(); }
public void AddReversal(LexReversal reversal) { if (!MultiTextBase.IsEmpty(reversal)) { Writer.WriteStartElement("reversal"); if (!string.IsNullOrEmpty(reversal.Type)) { Writer.WriteAttributeString("type", reversal.Type.Trim()); } AddMultitextForms(string.Empty, reversal); Writer.WriteEndElement(); } }
public void AddNote(LexNote note) { if (!MultiTextBase.IsEmpty(note)) { Writer.WriteStartElement("note"); if (!string.IsNullOrEmpty(note.Type)) { Writer.WriteAttributeString("type", note.Type.Trim()); } AddMultitextForms(string.Empty, note); Writer.WriteEndElement(); } }
private bool WriteMultiWithWrapperIfNonEmpty(string propertyName, string wrapperName, MultiText text) // review cp see WriteEmbeddedXmlCollection { if (!MultiTextBase.IsEmpty(text)) { Writer.WriteStartElement(wrapperName); AddMultitextForms(propertyName, text); // review cp see WriteEmbeddedXmlCollection if (text is IExtensible) { WriteExtensible((IExtensible)text); } Writer.WriteEndElement(); return(true); } return(false); }
/// <summary> /// use this for multitexts that were somehow constructed during export, with no corresponding single property /// </summary> private void WriteMultiTextAsArtificialField(string outputFieldName, MultiTextBase text) { if (!MultiTextBase.IsEmpty(text)) { Writer.WriteStartElement("field"); Writer.WriteAttributeString("type", outputFieldName); if (!MultiTextBase.IsEmpty(text)) { var textWritingSystems = _viewTemplate.WritingSystems.TextWritingSystems; var ids = from ws in textWritingSystems select ws.Id; WriteLanguageFormsInWrapper(text.Forms.Where(f => ids.Contains(f.WritingSystemId)), "form", true); } Writer.WriteEndElement(); } }
private void WriteGlossOneElementPerFormIfNonEmpty(MultiTextBase text) { if (MultiTextBase.IsEmpty(text)) { return; } foreach (var form in GetOrderedAndFilteredForms(text, LexSense.WellKnownProperties.Gloss)) { if (string.IsNullOrEmpty(form.Form)) { continue; } Writer.WriteStartElement("gloss"); Writer.WriteAttributeString("lang", form.WritingSystemId); Writer.WriteStartElement("text"); Writer.WriteString(form.Form); Writer.WriteEndElement(); WriteFlags(form); Writer.WriteEndElement(); } }
private static bool IsPropertyEmpty(object property) { if (property is MultiText) { return(MultiTextBase.IsEmpty((MultiText)property)); } else if (property is OptionRef) { return(((OptionRef)property).IsEmpty); } else if (property is OptionRefCollection) { return(((OptionRefCollection)property).IsEmpty); } else if (property is IReportEmptiness) { return(((IReportEmptiness)property).ShouldBeRemovedFromParentDueToEmptiness); } // Debug.Fail("Unknown property type"); return(false); //don't throw it away if you don't know what it is }