Exemple #1
0
        public void MultilingualStringBasedonStringDictionary()
        {
            FdoReferenceSequence <ILgWritingSystem> systems = Cache.LangProject.CurVernWssRS;
            ILexDb    ld = Cache.LangProject.LexDbOA;
            ILexEntry le = MakeLexEntry(ld, "xyzTest1", "xyzDefn1.1", 0);
            IMoForm   m  = MoForm.MakeMorph(Cache, le, "-is");

            m.Form.SetAlternative("iz", systems[1].Hvo);

            string t      = "<entry><objAtomic objProperty='LexemeFormOA'/></entry>";
            string c      = "<class name='MoForm'><multilingualStringElement name='form' simpleProperty='NamesWithMarkers'/></class>";
            string result = GetResultStringFromEntry(le, t, c);

            Assert.AreEqual("<entry><form ws=\"fr\">-is</form>\r\n<form ws=\"ur\">-iz</form>\r\n</entry>", result.Trim());
        }
Exemple #2
0
		public void MultilingualStringBasedonStringDictionary()
		{
			FdoReferenceSequence<LgWritingSystem> systems = Cache.LangProject.CurVernWssRS;
			LexDb ld = Cache.LangProject.LexDbOA;
			LexEntry le = MakeLexEntry("xyzTest1", "xyzDefn1.1", null);
			MoForm m = MoForm.MakeMorph(le, "-is");
			// It will already have the right form.
			//m.FormAccessor.set_String(systems[1].Hvo, Cache.TsStrFactory.MakeString("iz", systems[1].Hvo));

			string t = "<entry><objAtomic objProperty='LexemeFormOA'/></entry>";
			string c = "<class name='MoForm'><multilingualStringElement name='form' simpleProperty='NamesWithMarkers'/></class>";
			string result = GetResultStringFromEntry(le, t, c);

			Assert.AreEqual(String.Format("<entry><form ws=\"fr\">-is</form>{0}<form ws=\"ur\">-iz</form>{0}</entry>", Environment.NewLine), result.Trim());
		}
Exemple #3
0
        public void Initialize(MoForm rootObj, int rootFlid, FdoCache cache)
        {
            CheckDisposed();

            Debug.Assert(rootObj is MoAffixAllomorph || rootObj is MoStemAllomorph);
            Debug.Assert(cache != null && m_fdoCache == null);
            m_fdoCache = cache;
            ResetValidator();
            m_wsVern   = m_fdoCache.LangProject.DefaultVernacularWritingSystem;
            m_rootObj  = rootObj;
            m_rootFlid = rootFlid;
            if (m_rootb == null)
            {
                MakeRoot();
            }
        }
Exemple #4
0
        public void MergeInLexemeForm(ILexEntry entry, SimpleMultiText forms)
        {
            if (entry.LexemeFormOA == null)
            {
                //base the type on the first form

                string form = forms.FirstValue.Value;                //<---HACK. What to do here?
                if (form == null)
                {
                    return;
                }
                //TODO!!!!!!!!!!!!!!!!!!!!! beware ws order assumption here:
                entry.LexemeFormOA = MoForm.MakeMorph(_cache, entry, form);
            }

            // now merge in the rest
            MergeIn(entry.LexemeFormOA.Form, forms);
        }
Exemple #5
0
        private void cbShowAllTypes_CheckedChanged(object sender, System.EventArgs e)
        {
            // If a node is selected, try selecting again when we get through.
            int       hvoSelected = SelectedHvo;
            Set <int> candidates  = null;
            string    displayWs   = "best analorvern";

            if (cbShowAllTypes.Checked)
            {
                MoForm form = m_obj as MoForm;
                candidates = form.GetAllMorphTypeReferenceTargetCandidates();
            }
            else
            {
                candidates = m_obj.ReferenceTargetCandidates(m_flid);
            }
            ObjectLabelCollection labels = new ObjectLabelCollection(m_cache, candidates,
                                                                     m_displayNameProperty, displayWs);

            LoadTree(labels, 0, false);
            MakeSelection(hvoSelected);
        }
Exemple #6
0
        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        protected override void Dispose(bool disposing)
        {
            //Debug.WriteLineIf(!disposing, "****************** " + GetType().Name + " 'disposing' is false. ******************");
            // Must not be run more than once.
            if (IsDisposed)
            {
                return;
            }

            base.Dispose(disposing);

            if (disposing)
            {
                if (components != null)
                {
                    components.Dispose();
                }
                if (m_PhoneEnvReferenceVc != null)
                {
                    m_PhoneEnvReferenceVc.Dispose();
                }
            }
            m_validator = null;             // TODO: Make m_validator disposable?
            m_realEnvs.Clear();
            m_realEnvs = null;
            m_rootObj  = null;
            if (m_tsf != null)
            {
                System.Runtime.InteropServices.Marshal.ReleaseComObject(m_tsf);
            }
            m_tsf      = null;
            m_silCache = null;
            if (m_vwCache != null)
            {
                System.Runtime.InteropServices.Marshal.ReleaseComObject(m_vwCache);
            }
            m_vwCache             = null;
            m_PhoneEnvReferenceVc = null;
        }
Exemple #7
0
        protected void ConvertMorphs(XmlDocument doc, string sNodeListToFind, bool fIdsInAttribute)
        {
            XmlNodeList nl = doc.SelectNodes(sNodeListToFind);

            if (nl != null)
            {
                foreach (XmlNode node in nl)
                {
                    XmlNode alloid;
                    if (fIdsInAttribute)
                    {
                        alloid = node.Attributes.GetNamedItem("alloid");
                    }
                    else
                    {
                        alloid = node.SelectSingleNode("MoForm/@DbRef");
                    }
                    int     hvo  = Convert.ToInt32(alloid.InnerText);
                    IMoForm form = MoForm.CreateFromDBObject(m_cache, hvo);
                    string  sLongName;
                    string  sForm;
                    string  sGloss;
                    string  sCitationForm;
                    if (form != null)
                    {
                        sLongName = form.LongName;
                        int iFirstSpace = sLongName.IndexOf(" (");
                        int iLastSpace  = sLongName.LastIndexOf("):") + 2;
                        sForm = sLongName.Substring(0, iFirstSpace);
                        XmlNode msaid;
                        if (fIdsInAttribute)
                        {
                            msaid = node.Attributes.GetNamedItem("morphname");
                        }
                        else
                        {
                            msaid = node.SelectSingleNode("MSI/@DbRef");
                        }
                        int hvoMsa = Convert.ToInt32(msaid.InnerText);
                        IMoMorphSynAnalysis msa = MoMorphSynAnalysis.CreateFromDBObject(m_cache, hvoMsa);
                        if (msa != null)
                        {
                            sGloss = msa.GetGlossOfFirstSense();
                        }
                        else
                        {
                            sGloss = sLongName.Substring(iFirstSpace, iLastSpace - iFirstSpace).Trim();
                        }
                        sCitationForm = sLongName.Substring(iLastSpace).Trim();
                        sLongName     = String.Format(ParserUIStrings.ksX_Y_Z, sForm, sGloss, sCitationForm);
                    }
                    else
                    {
                        sForm         = ParserUIStrings.ksUnknownMorpheme;                 // in case the user continues...
                        sGloss        = ParserUIStrings.ksUnknownGloss;
                        sCitationForm = ParserUIStrings.ksUnknownCitationForm;
                        sLongName     = String.Format(ParserUIStrings.ksX_Y_Z, sForm, sGloss, sCitationForm);
                        throw new ApplicationException(sLongName);
                    }
                    XmlNode tempNode = CreateXmlElement(doc, "shortName", node);
                    tempNode.InnerXml = CreateEntities(sLongName);
                    tempNode          = CreateXmlElement(doc, "alloform", node);
                    tempNode.InnerXml = CreateEntities(sForm);
                    switch (form.ClassID)
                    {
                    case MoStemAllomorph.kclsidMoStemAllomorph:
                        ConvertStemName(doc, node, form, tempNode);
                        break;

                    case MoAffixAllomorph.kclsidMoAffixAllomorph:
                        ConvertAffixAlloFeats(doc, node, form, tempNode);
                        ConvertStemNameAffix(doc, node, tempNode);
                        break;
                    }
                    tempNode          = CreateXmlElement(doc, "gloss", node);
                    tempNode.InnerXml = CreateEntities(sGloss);
                    tempNode          = CreateXmlElement(doc, "citationForm", node);
                    tempNode.InnerXml = CreateEntities(sCitationForm);
                }
            }
        }