예제 #1
0
        public void Persistence()
        {
            var wsManager = new WritingSystemManager();
            CoreWritingSystemDefinition enWs;

            wsManager.GetOrSet("en", out enWs);
            int wsEng = enWs.Handle;

            CoreWritingSystemDefinition frWs;

            wsManager.GetOrSet("fr", out frWs);
            int wsFrn = frWs.Handle;

            CoreWritingSystemDefinition deWs;

            wsManager.GetOrSet("de", out deWs);
            int wsGer = deWs.Handle;

            InterlinLineChoices choices = new InterlinLineChoices(m_lp, wsFrn, wsEng);

            MakeStandardState(choices);
            string persist = choices.Persist(wsManager);

            choices = InterlinLineChoices.Restore(persist, wsManager, m_lp, wsFrn, wsEng);

            Assert.AreEqual(InterlinLineChoices.kflidWord, choices[0].Flid);
            Assert.AreEqual(InterlinLineChoices.kflidMorphemes, choices[1].Flid);
            Assert.AreEqual(InterlinLineChoices.kflidLexEntries, choices[2].Flid);
            Assert.AreEqual(InterlinLineChoices.kflidLexGloss, choices[3].Flid);
            Assert.AreEqual(InterlinLineChoices.kflidLexPos, choices[4].Flid);
            Assert.AreEqual(InterlinLineChoices.kflidWordGloss, choices[5].Flid);
            Assert.AreEqual(InterlinLineChoices.kflidWordPos, choices[6].Flid);
            Assert.AreEqual(InterlinLineChoices.kflidFreeTrans, choices[7].Flid);
            Assert.AreEqual(InterlinLineChoices.kflidLitTrans, choices[8].Flid);

            // Check writing systems assigned by default.
            Assert.AreEqual(wsFrn, choices[0].WritingSystem);
            Assert.AreEqual(wsEng, choices[5].WritingSystem);
            Assert.AreEqual(wsFrn, choices[2].WritingSystem);

            choices = new EditableInterlinLineChoices(m_lp, 0, wsEng);
            MakeStandardState(choices);
            choices.Add(InterlinLineChoices.kflidLexGloss, wsGer);
            Assert.AreEqual(InterlinLineChoices.kflidWord, choices[0].Flid);
            Assert.AreEqual(InterlinLineChoices.kflidMorphemes, choices[1].Flid);
            Assert.AreEqual(InterlinLineChoices.kflidLexEntries, choices[2].Flid);
            Assert.AreEqual(InterlinLineChoices.kflidLexGloss, choices[3].Flid);
            Assert.AreEqual(InterlinLineChoices.kflidLexGloss, choices[4].Flid);
            Assert.AreEqual(InterlinLineChoices.kflidLexPos, choices[5].Flid);
            Assert.AreEqual(InterlinLineChoices.kflidWordGloss, choices[6].Flid);
            Assert.AreEqual(InterlinLineChoices.kflidWordPos, choices[7].Flid);
            Assert.AreEqual(InterlinLineChoices.kflidFreeTrans, choices[8].Flid);
            Assert.AreEqual(InterlinLineChoices.kflidLitTrans, choices[9].Flid);

            Assert.AreEqual(wsGer, choices[4].WritingSystem);
        }
예제 #2
0
        public void Persistence()
        {
            ILgWritingSystemFactory wsf = LgWritingSystemFactoryClass.Create();

            try
            {
                int wsEng = 1;
                int wsFrn = 2;
                int wsGer = 3;
                wsf.AddWritingSystem(wsEng, "en");
                wsf.AddWritingSystem(wsFrn, "fr");
                wsf.AddWritingSystem(wsGer, "de");
                InterlinLineChoices choices = new InterlinLineChoices(wsFrn, wsEng);
                MakeStandardState(choices);
                string persist = choices.Persist(wsf);
                choices = InterlinLineChoices.Restore(persist, wsf, wsFrn, wsEng);

                Assert.AreEqual(InterlinLineChoices.kflidWord, choices[0].Flid);
                Assert.AreEqual(InterlinLineChoices.kflidMorphemes, choices[1].Flid);
                Assert.AreEqual(InterlinLineChoices.kflidLexEntries, choices[2].Flid);
                Assert.AreEqual(InterlinLineChoices.kflidLexGloss, choices[3].Flid);
                Assert.AreEqual(InterlinLineChoices.kflidLexPos, choices[4].Flid);
                Assert.AreEqual(InterlinLineChoices.kflidWordGloss, choices[5].Flid);
                Assert.AreEqual(InterlinLineChoices.kflidWordPos, choices[6].Flid);
                Assert.AreEqual(InterlinLineChoices.kflidFreeTrans, choices[7].Flid);
                Assert.AreEqual(InterlinLineChoices.kflidLitTrans, choices[8].Flid);

                // Check writing systems assigned by default.
                Assert.AreEqual(wsFrn, choices[0].WritingSystem);
                Assert.AreEqual(wsEng, choices[5].WritingSystem);
                Assert.AreEqual(wsFrn, choices[2].WritingSystem);

                choices = new EditableInterlinLineChoices(0, wsEng);
                MakeStandardState(choices);
                choices.Add(InterlinLineChoices.kflidLexGloss, wsGer);
                Assert.AreEqual(InterlinLineChoices.kflidWord, choices[0].Flid);
                Assert.AreEqual(InterlinLineChoices.kflidMorphemes, choices[1].Flid);
                Assert.AreEqual(InterlinLineChoices.kflidLexEntries, choices[2].Flid);
                Assert.AreEqual(InterlinLineChoices.kflidLexGloss, choices[3].Flid);
                Assert.AreEqual(InterlinLineChoices.kflidLexGloss, choices[4].Flid);
                Assert.AreEqual(InterlinLineChoices.kflidLexPos, choices[5].Flid);
                Assert.AreEqual(InterlinLineChoices.kflidWordGloss, choices[6].Flid);
                Assert.AreEqual(InterlinLineChoices.kflidWordPos, choices[7].Flid);
                Assert.AreEqual(InterlinLineChoices.kflidFreeTrans, choices[8].Flid);
                Assert.AreEqual(InterlinLineChoices.kflidLitTrans, choices[9].Flid);

                Assert.AreEqual(wsGer, choices[4].WritingSystem);
            }
            finally
            {
                // we must shutdown and marshal this or else it could mess up other tests.
                wsf.Shutdown();
                System.Runtime.InteropServices.Marshal.ReleaseComObject(wsf);
            }
        }
예제 #3
0
        /// <summary>
        /// Tries to restore the LineChoices saved in the ConfigPropName property in the property table.
        /// </summary>
        /// <param name="lineChoices"></param>
        /// <returns></returns>
        internal bool TryRestoreLineChoices(out InterlinLineChoices lineChoices)
        {
            lineChoices = null;
            var persist = m_propertyTable.GetStringProperty(ConfigPropName, null, PropertyTable.SettingsGroup.LocalSettings);

            if (persist != null)
            {
                lineChoices = InterlinLineChoices.Restore(persist, m_cache.LanguageWritingSystemFactoryAccessor,
                                                          m_cache.LangProject, WritingSystemServices.kwsVernInParagraph, m_cache.DefaultAnalWs, InterlinLineChoices.InterlinMode.Analyze, m_propertyTable, ConfigPropName);
            }
            return(persist != null && lineChoices != null);
        }