protected void CreateFromPOSNodes(XmlDocument doc, XmlNode msaNode, IFdoReferenceCollection <IPartOfSpeech> fromPOSes, string sElementName) { if (fromPOSes == null || fromPOSes.Count < 1) { return; } foreach (IPartOfSpeech pos in fromPOSes) { XmlNode posNode = CreateXmlElement(doc, sElementName, msaNode); CreateXmlAttribute(doc, "fromCat", pos.Hvo.ToString(), posNode); CreateXmlAttribute(doc, "fromCatAbbr", pos.Abbreviation.BestAnalysisAlternative.Text, posNode); } }
private static void WriteFromPosNodes(XmlWriter writer, IFdoReferenceCollection <IPartOfSpeech> fromPoSes, string sElementName) { if (fromPoSes == null || fromPoSes.Count < 1) { return; } foreach (IPartOfSpeech pos in fromPoSes) { writer.WriteStartElement(sElementName); writer.WriteAttributeString("fromCat", pos.Hvo.ToString(CultureInfo.InvariantCulture)); writer.WriteAttributeString("fromCatAbbr", pos.Abbreviation.BestAnalysisAlternative.Text); writer.WriteEndElement(); //sElementName } }
private static void WriteProductivityRestrictionNodes(XmlWriter writer, IFdoReferenceCollection <ICmPossibility> prodRests, string sElementName) { if (prodRests == null || prodRests.Count < 1) { return; } foreach (ICmPossibility pr in prodRests) { writer.WriteStartElement(sElementName); writer.WriteAttributeString("id", pr.Hvo.ToString(CultureInfo.InvariantCulture)); writer.WriteElementString("name", pr.Name.BestAnalysisAlternative.Text); writer.WriteEndElement(); //sElementName } }
private void RemoveReversalEntryFromSense() { if (m_selectedSenseHvo == 0) { return; // must be selecting multiple objects! (See LT-5724.) } int h1 = m_rootb.Height; ILexSense sense = (ILexSense)m_fdoCache.ServiceLocator.GetObject(m_selectedSenseHvo); IFdoReferenceCollection <IReversalIndexEntry> col = sense.ReversalEntriesRC; using (UndoableUnitOfWorkHelper helper = new UndoableUnitOfWorkHelper( m_fdoCache.ActionHandlerAccessor, SIL.FieldWorks.XWorks.LexEd.LexEdStrings.ksUndoDeleteRevFromSense, SIL.FieldWorks.XWorks.LexEd.LexEdStrings.ksRedoDeleteRevFromSense)) { sense.ReversalEntriesRC.Remove(m_rootObj as IReversalIndexEntry); helper.RollBack = false; } CheckViewSizeChanged(h1, m_rootb.Height); }
public override void AddItem(ICmObject obj) { CheckDisposed(); ILexSense selectedSense = obj as ILexSense; IFdoReferenceCollection <IReversalIndexEntry> col = selectedSense.ReversalEntriesRC; if (!col.Contains(m_obj as IReversalIndexEntry)) { int h1 = m_vectorRefView.RootBox.Height; using (UndoableUnitOfWorkHelper helper = new UndoableUnitOfWorkHelper( m_cache.ActionHandlerAccessor, LexEdStrings.ksUndoAddRevToSense, LexEdStrings.ksRedoAddRevToSense)) { col.Add(m_obj as IReversalIndexEntry); helper.RollBack = false; } int h2 = m_vectorRefView.RootBox.Height; CheckViewSizeChanged(h1, h2); } }
protected void CreateMorphInflectionClassesXmlElement(XmlDocument doc, XmlNode node, XmlNode morphNode) { XmlNode attr; attr = node.SelectSingleNode("@alloid"); if (attr != null) { XmlNode alloid = node.Attributes.GetNamedItem("alloid"); int hvo = Convert.ToInt32(alloid.InnerText); ICmObject obj = m_cache.ServiceLocator.GetInstance <ICmObjectRepository>().GetObject(hvo); IMoAffixForm form = obj as IMoAffixForm; // only for affix forms if (form != null) { if (form.InflectionClassesRC.Count > 0) { XmlNode inflClasses = CreateXmlElement(doc, "inflClasses", morphNode); IFdoReferenceCollection <IMoInflClass> inflectionClasses = form.InflectionClassesRC; CreateInflectionClassesAndSubclassesXmlElement(doc, inflectionClasses, inflClasses); } } } }
// This function is generic because some lists, like ILexSense.AnthroCodesRC, are lists of interfaces *derived* // from ICmPossibility (e.g., ICmAnthroItem). This results in type errors at compile time: parameter // types like IFdoReferenceCollection<ICmPossibility> don't match IFdoReferenceCollection<ICmAnthroCode>. // Generics solve the problem, and can be automatically inferred by the compiler to boot. public void SetPossibilitiesCollection <T>(IFdoReferenceCollection <T> dest, IEnumerable <T> newItems) where T : class, ICmPossibility { // If we know of NO valid possibility keys, don't make any changes. That's because knowing of NO valid possibility keys // is FAR more likely to happen because of a bug than because we really removed an entire possibility list, and if there's // a bug, we shouldn't drop all the FDO data for this possibility list. if (PossibilitiesByKey.Count == 0 && _canonicalSource == null) { return; } // We have to calculate the update (which items to remove and which to add) here; IFdoReferenceCollection won't do it for us. List <T> itemsToAdd = newItems.ToList(); HashSet <Guid> guidsToAdd = new HashSet <Guid>(itemsToAdd.Select(poss => poss.Guid)); List <T> itemsToRemove = new List <T>(); foreach (T poss in dest) { if (!guidsToAdd.Contains(poss.Guid)) { itemsToRemove.Add(poss); } } dest.Replace(itemsToRemove, itemsToAdd); }
private static void WriteFromPosNodes(XmlWriter writer, IFdoReferenceCollection<IPartOfSpeech> fromPoSes, string sElementName) { if (fromPoSes == null || fromPoSes.Count < 1) return; foreach (IPartOfSpeech pos in fromPoSes) { writer.WriteStartElement(sElementName); writer.WriteAttributeString("fromCat", pos.Hvo.ToString(CultureInfo.InvariantCulture)); writer.WriteAttributeString("fromCatAbbr", pos.Abbreviation.BestAnalysisAlternative.Text); writer.WriteEndElement(); //sElementName } }
private static void WriteProductivityRestrictionNodes(XmlWriter writer, IFdoReferenceCollection<ICmPossibility> prodRests, string sElementName) { if (prodRests == null || prodRests.Count < 1) return; foreach (ICmPossibility pr in prodRests) { writer.WriteStartElement(sElementName); writer.WriteAttributeString("id", pr.Hvo.ToString(CultureInfo.InvariantCulture)); writer.WriteElementString("name", pr.Name.BestAnalysisAlternative.Text); writer.WriteEndElement(); //sElementName } }
// Assumption: "source" contains valid keys. CAUTION: No error checking is done to ensure that this is true. public void UpdatePossibilitiesFromStringArray <T>(IFdoReferenceCollection <T> dest, LfStringArrayField source) where T : class, ICmPossibility { SetPossibilitiesCollection(dest, FromStringArrayField <T>(source)); }
protected void CreateProductivityRestrictionNodes(XmlDocument doc, XmlNode msaNode, IFdoReferenceCollection <ICmPossibility> prodRests, string sElementName) { if (prodRests == null || prodRests.Count < 1) { return; } foreach (ICmPossibility pr in prodRests) { XmlNode prNode = CreateXmlElement(doc, sElementName, msaNode); CreateXmlAttribute(doc, "id", pr.Hvo.ToString(), prNode); XmlNode prName = CreateXmlElement(doc, "name", prNode); prName.InnerText = pr.Name.BestAnalysisAlternative.Text; } }