Example #1
0
        public void CountPropertyTests()
        {
            IFdoServiceLocator servLoc = Cache.ServiceLocator;
            ILangProject       lp      = Cache.LanguageProject;
            ILexDb             lexDb   = lp.LexDbOA;
            ILexEntry          le      = servLoc.GetInstance <ILexEntryFactory>().Create();
            ILexSense          sense   = servLoc.GetInstance <ILexSenseFactory>().Create();

            le.SensesOS.Add(sense);

            // FdoReferenceCollection
            int originalCount = lexDb.LexicalFormIndexRC.Count;

            lexDb.LexicalFormIndexRC.Add(le);
            Assert.AreEqual(originalCount + 1, lexDb.LexicalFormIndexRC.Count);
            lexDb.LexicalFormIndexRC.Remove(le);
            Assert.AreEqual(originalCount, lexDb.LexicalFormIndexRC.Count);

            // FdoReferenceSequence
            originalCount = le.MainEntriesOrSensesRS.Count;
            le.MainEntriesOrSensesRS.Add(sense);
            Assert.AreEqual(originalCount + 1, le.MainEntriesOrSensesRS.Count);
            le.MainEntriesOrSensesRS.RemoveAt(le.MainEntriesOrSensesRS.Count - 1);
            Assert.AreEqual(originalCount, le.MainEntriesOrSensesRS.Count);
        }
Example #2
0
        public void AddTo_RefColToRefCol()
        {
            IFdoServiceLocator servLoc = Cache.ServiceLocator;
            ILangProject       lp      = Cache.LanguageProject;
            ILexDb             lexDb   = lp.LexDbOA;
            ILexAppendix       app1    = servLoc.GetInstance <ILexAppendixFactory>().Create();

            lexDb.AppendixesOC.Add(app1);
            ILexAppendix app2 = servLoc.GetInstance <ILexAppendixFactory>().Create();

            lexDb.AppendixesOC.Add(app2);
            ILexEntry le1    = servLoc.GetInstance <ILexEntryFactory>().Create();
            ILexSense sense1 = servLoc.GetInstance <ILexSenseFactory>().Create();

            le1.SensesOS.Add(sense1);
            ILexSense sense2 = servLoc.GetInstance <ILexSenseFactory>().Create();

            le1.SensesOS.Add(sense2);

            sense1.AppendixesRC.Add(app1);
            sense1.AppendixesRC.Add(app2);

            sense1.AppendixesRC.AddTo(sense2.AppendixesRC);

            Assert.AreEqual(2, sense2.AppendixesRC.Count);
            Assert.IsTrue(sense2.AppendixesRC.Contains(app1));
            Assert.IsTrue(sense2.AppendixesRC.Contains(app2));
        }
Example #3
0
        /// <summary>
        /// Get the values we want for the occurrences of the specified LexSE HVO.
        /// </summary>
        /// <param name="hvo"></param>
        /// <returns></returns>
        int[] GetSenseOccurrences(int hvo)
        {
            int[] values;
            if (m_values.TryGetValue(hvo, out values))
            {
                return(values);
            }
            var sense      = m_services.GetInstance <ILexSenseRepository>().GetObject(hvo);
            var bundles    = m_services.GetInstance <IWfiMorphBundleRepository>().InstancesWithSense(sense);
            var valuesList = new List <int>();

            foreach (IWfiAnalysis wa in (from bundle in bundles select bundle.Owner).Distinct())
            {
                var bag = ((IWfiWordform)wa.Owner).OccurrencesBag;
                foreach (var seg in from item in bag.Items where BelongsToInterestingText(item) select item)
                {
                    foreach (var occurrence in seg.GetOccurrencesOfAnalysis(wa, bag.Occurrences(seg), true))
                    {
                        int hvoOcc = m_nextId--;
                        valuesList.Add(hvoOcc);
                        m_occurrences[hvoOcc] = occurrence;
                    }
                }
            }
            values        = valuesList.ToArray();
            m_values[hvo] = values;
            return(values);
        }
Example #4
0
        /// <summary>
        /// Make an individual spelling dictionary conform as closely as possible to the spelling status
        /// recorded in Wordforms.
        /// </summary>
        /// <param name="ws"></param>
        /// <param name="cache"></param>
        public static void ConformOneSpellingDictToWordforms(int ws, FdoCache cache)
        {
            IFdoServiceLocator servloc = cache.ServiceLocator;
            var lgwsFactory            = servloc.GetInstance <ILgWritingSystemFactory>();
            var dict = SpellingHelper.GetSpellChecker(ws, lgwsFactory);

            if (dict == null)
            {
                return;
            }
            // we only force one to exist for the default, others might not have one.
            var words = new List <string>();

            foreach (IWfiWordform wf in servloc.GetInstance <IWfiWordformRepository>().AllInstances())
            {
                if (wf.SpellingStatus != (int)SpellingStatusStates.correct)
                {
                    continue;                     // don't put it in the list of correct words
                }
                string wordform = wf.Form.get_String(ws).Text;
                if (!string.IsNullOrEmpty(wordform))
                {
                    words.Add(wordform);
                }
            }
            SpellingHelper.ResetDictionary(SpellingHelper.DictionaryId(ws, lgwsFactory), words);
        }
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Make the external spelling dictionary conform as closely as possible to the spelling
        /// status recorded in the Wordforms. We try to keep these in sync, but when we first
        /// create an external spelling dictionary we need to make it match, and even later, on
        /// restoring a backup or when a user on another computer changed the database, we may
        /// need to re-synchronize. The best we can do is to Add all the words we know are
        /// correct and remove all the others we know about at all; it's possible that a
        /// wordform that was previously correct and is now deleted will be thought correct by
        /// the dictionary. In the case of a major language, of course, it's also possible that
        /// words that were never in our inventory at all will be marked correct. This is the
        /// best we know how to do.
        ///
        /// We also force there to be an external spelling dictionary for the default vernacular WS;
        /// others are updated only if they already exist.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        public static void ConformSpellingDictToWordforms(FdoCache cache)
        {
            // Force a dictionary to exist for the default vernacular writing system.
            IFdoServiceLocator servloc = cache.ServiceLocator;
            var lgwsFactory            = servloc.GetInstance <ILgWritingSystemFactory>();

            using (EnchantHelper.EnsureDictionary(cache.DefaultVernWs, lgwsFactory))
            {
            }

            // Make all existing spelling dictionaries give as nearly as possible the right answers.
            foreach (IWritingSystem wsObj in cache.ServiceLocator.WritingSystems.VernacularWritingSystems)
            {
                int ws = wsObj.Handle;
                using (var dict = EnchantHelper.GetDictionary(ws, lgwsFactory))
                {
                    if (dict == null)
                    {
                        continue;
                    }
                    // we only force one to exist for the default, others might not have one.
                    foreach (IWfiWordform wf in servloc.GetInstance <IWfiWordformRepository>().AllInstances())
                    {
                        string wordform = wf.Form.get_String(ws).Text;
                        if (!string.IsNullOrEmpty(wordform))
                        {
                            EnchantHelper.SetSpellingStatus(wordform,
                                                            wf.SpellingStatus == (int)SpellingStatusStates.correct, dict);
                        }
                    }
                }
            }
        }
Example #6
0
        public void IndexedSetter_EmptyList()
        {
            IFdoServiceLocator servLoc = Cache.ServiceLocator;

            Cache.LangProject.CheckListsOC.Add(servLoc.GetInstance <ICmPossibilityListFactory>().Create());
            Cache.LangProject.CheckListsOC.First().PossibilitiesOS[0] =
                servLoc.GetInstance <ICmPossibilityFactory>().Create();
        }
		/// <summary>
		/// set up member variables and test data.
		/// </summary>
		protected override void CreateTestData()
		{
			base.CreateTestData();
			m_servLoc = Cache.ServiceLocator;
			m_servLoc.GetInstance<IVirtualOrderingFactory>();
			m_voRepo = m_servLoc.GetInstance<IVirtualOrderingRepository>();
			m_possFact = m_servLoc.GetInstance<ICmPossibilityFactory>();
			CreateKnownPossibilityList();
		}
		/// <summary>
		/// Create test data for ReferenceAdjusterService tests.
		/// </summary>
		protected override void CreateTestData()
		{
			base.CreateTestData();
			m_servLoc = Cache.ServiceLocator;
			m_raService = m_servLoc.GetInstance<IReferenceAdjuster>();
			m_tagFact = m_servLoc.GetInstance<ITextTagFactory>();

			CreateTestText();
		}
Example #9
0
 /// <summary>
 /// set up member variables and test data.
 /// </summary>
 protected override void CreateTestData()
 {
     base.CreateTestData();
     m_servLoc = Cache.ServiceLocator;
     m_servLoc.GetInstance <IVirtualOrderingFactory>();
     m_voRepo   = m_servLoc.GetInstance <IVirtualOrderingRepository>();
     m_possFact = m_servLoc.GetInstance <ICmPossibilityFactory>();
     CreateKnownPossibilityList();
 }
        /// <summary>
        /// Create test data for ReferenceAdjusterService tests.
        /// </summary>
        protected override void CreateTestData()
        {
            base.CreateTestData();
            m_servLoc   = Cache.ServiceLocator;
            m_raService = m_servLoc.GetInstance <IReferenceAdjuster>();
            m_tagFact   = m_servLoc.GetInstance <ITextTagFactory>();

            CreateTestText();
        }
Example #11
0
        /// <summary>
        /// Make and parse a new paragraph and append it to the current text.
        /// In this version the test specifies the text (so it can know how many
        /// words it has.
        /// </summary>
        /// <returns></returns>
        internal IStTxtPara MakeParagraphSpecificContent(string content)
        {
            var para0 = m_servLoc.GetInstance <IStTxtParaFactory>().Create();

            m_stText.ParagraphsOS.Add(para0);
            var tsstring = m_tsf.MakeString(content, Cache.DefaultVernWs);

            para0.Contents = tsstring;
            ParseTestParagraphWithSpecificContent(para0);
            return(para0);
        }
Example #12
0
        private void CreateFakeGenreList()
        {
            // this list is null in the FdoTestBase.
            Cache.LangProject.GenreListOA = m_servLoc.GetInstance <ICmPossibilityListFactory>().Create();
            Assert.AreEqual(0, Cache.LangProject.GenreListOA.PossibilitiesOS.Count);

            AppendGenreItemToFakeGenreList("First");
            AppendGenreItemToFakeGenreList("Second");
            AppendGenreItemToFakeGenreList("Third");
            AppendGenreItemToFakeGenreList("Fourth");
        }
Example #13
0
        public void AddNullItem2ToVectorTest()
        {
            IFdoServiceLocator servLoc = Cache.ServiceLocator;
            ILangProject       lp      = Cache.LanguageProject;
            ILexEntry          le      = servLoc.GetInstance <ILexEntryFactory>().Create();
            ILexSense          sense   = servLoc.GetInstance <ILexSenseFactory>().Create();

            le.SensesOS.Add(sense);

            le.MainEntriesOrSensesRS.Add(sense);
            le.MainEntriesOrSensesRS[0] = null;             // Should throw the exception.
        }
Example #14
0
        private IWfiWordform FindOrCreateWordform(string form)
        {
            IFdoServiceLocator servLoc = Cache.ServiceLocator;
            IWfiWordform       wf      = servLoc.GetInstance <IWfiWordformRepository>().GetMatchingWordform(m_vernacularWS.Handle, form);

            if (wf == null)
            {
                UndoableUnitOfWorkHelper.Do("Undo create", "Redo create", m_actionHandler,
                                            () => wf = servLoc.GetInstance <IWfiWordformFactory>().Create(Cache.TsStrFactory.MakeString(form, m_vernacularWS.Handle)));
            }
            return(wf);
        }
Example #15
0
        public void Insert_UnownableObject()
        {
            IFdoServiceLocator servLoc  = Cache.ServiceLocator;
            IScrBookFactory    bookFact = servLoc.GetInstance <IScrBookFactory>();

            // Setup the source sequence using the scripture books sequence.
            IStText       text;
            IScrBook      book0       = bookFact.Create(1, out text);
            IStTxtPara    para        = text.AddNewTextPara(ScrStyleNames.MainBookTitle);
            IScrRefSystem systemToAdd = servLoc.GetInstance <IScrRefSystemRepository>().Singleton;

            para.AnalyzedTextObjectsOS.Insert(0, systemToAdd);
        }
Example #16
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Adds an interlinear text to the language projectin the mocked fdocache
        /// </summary>
        /// <param name="name">The name (in English).</param>
        /// <param name="fCreateContents">if set to <c>true</c> also creates an StText for the
        /// Contents.</param>
        /// <returns>The new text</returns>
        /// ------------------------------------------------------------------------------------
        public IText AddInterlinearTextToLangProj(string name, bool fCreateContents)
        {
            IFdoServiceLocator servloc = Cache.ServiceLocator;
            IText text = servloc.GetInstance <ITextFactory>().Create();
            //Cache.LangProject.TextsOC.Add(text);
            int wsEn = servloc.GetInstance <ILgWritingSystemFactory>().GetWsFromStr("en");

            text.Name.set_String(wsEn, name);

            if (fCreateContents)
            {
                text.ContentsOA = servloc.GetInstance <IStTextFactory>().Create();
            }
            return(text);
        }
		static public InterestingTextList GetInterestingTextList(Mediator mediator, IFdoServiceLocator services)
		{
			var interestingTextList = mediator.PropertyTable.GetValue(InterestingTextKey, null) as InterestingTextList;
			if (interestingTextList == null)
			{
				interestingTextList = new InterestingTextList(mediator.PropertyTable, services.GetInstance<ITextRepository>(),
					services.GetInstance<IStTextRepository>(), FwUtils.IsOkToDisplayScriptureIfPresent);
				// Make this list available for other tools in this window, but don't try to persist it.
				mediator.PropertyTable.SetProperty(InterestingTextKey, interestingTextList, false);
				mediator.PropertyTable.SetPropertyPersistence(InterestingTextKey, false);
				// Since the list hangs around indefinitely, it indefinitely monitors prop changes.
				// I can't find any way to make sure it eventually gets removed from the notification list.
				services.GetInstance<ISilDataAccessManaged>().AddNotification(interestingTextList);
			}
			return interestingTextList;
		}
        internal GhostParentHelper(IFdoServiceLocator services, int parentClsid, int flidOwning)
        {
            m_services    = services;
            m_parentClsid = parentClsid;
            m_flidOwning  = flidOwning;
            var mdc = m_services.GetInstance <IFwMetaDataCacheManaged>();

            TargetClass = mdc.GetDstClsId(flidOwning);
            switch ((CellarPropertyType)mdc.GetFieldType(flidOwning))
            {
            case CellarPropertyType.OwningAtomic:
                m_indexToCreate = -2;
                break;

            case CellarPropertyType.OwningCollection:
                m_indexToCreate = -1;
                break;

            case CellarPropertyType.OwningSequence:
                m_indexToCreate = 0;
                break;

            default:
                throw new InvalidOperationException("can only create objects in owning properties");
            }
        }
Example #19
0
        public void Insert_Null()
        {
            IFdoServiceLocator servLoc = Cache.ServiceLocator;

            IScrBook book0 = servLoc.GetInstance <IScrBookFactory>().Create(1);

            m_scr.ScriptureBooksOS.Insert(0, null);
        }
Example #20
0
        static public InterestingTextList GetInterestingTextList(Mediator mediator, IFdoServiceLocator services)
        {
            var interestingTextList = mediator.PropertyTable.GetValue(InterestingTextKey, null) as InterestingTextList;

            if (interestingTextList == null)
            {
                interestingTextList = new InterestingTextList(mediator.PropertyTable, services.GetInstance <ITextRepository>(),
                                                              services.GetInstance <IStTextRepository>(), FwUtils.IsTEInstalled);
                // Make this list available for other tools in this window, but don't try to persist it.
                mediator.PropertyTable.SetProperty(InterestingTextKey, interestingTextList, false);
                mediator.PropertyTable.SetPropertyPersistence(InterestingTextKey, false);
                // Since the list hangs around indefinitely, it indefinitely monitors prop changes.
                // I can't find any way to make sure it eventually gets removed from the notification list.
                services.GetInstance <ISilDataAccessManaged>().AddNotification(interestingTextList);
            }
            return(interestingTextList);
        }
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Creates a text for testing.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        private void CreateTestText()
        {
            m_txt = m_servLoc.GetInstance <ITextFactory>().Create();
            //Cache.LangProject.TextsOC.Add(m_txt);
            m_possTagList    = Cache.LangProject.GetDefaultTextTagList();
            m_stTxt          = m_servLoc.GetInstance <IStTextFactory>().Create();
            m_txt.ContentsOA = m_stTxt;
            m_txtPara        = m_txt.ContentsOA.AddNewTextPara(null);

            // 0    1  2 3    4      5   6                        7    8
            // This is a test string for ReferenceAdjusterService tests.

            var hvoVernWs = Cache.DefaultVernWs;

            m_txtPara.Contents = TsStringUtils.MakeTss("This is a test string for ReferenceAdjusterService tests.", hvoVernWs);
            ParseText();
        }
Example #22
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Adds an empty chart on the specified text.
        /// </summary>
        /// <param name="name">Chart name.</param>
        /// <param name="stText">Chart is BasedOn this text.</param>
        /// ------------------------------------------------------------------------------------
        private IDsConstChart AddChartToLangProj(string name, IStText stText)
        {
            IFdoServiceLocator servloc = Cache.ServiceLocator;
            IDsConstChart      chart   = servloc.GetInstance <IDsConstChartFactory>().Create();

            if (Cache.LangProject.DiscourseDataOA == null)
            {
                Cache.LangProject.DiscourseDataOA = servloc.GetInstance <IDsDiscourseDataFactory>().Create();
            }

            Cache.LangProject.DiscourseDataOA.ChartsOC.Add(chart);

            // Setup the new chart
            chart.Name.AnalysisDefaultWritingSystem = TsStringUtils.MakeTss(name, Cache.DefaultAnalWs);
            chart.BasedOnRA = stText;

            return(chart);            // This chart has no template or rows, so far!!
        }
 /// <summary>
 /// Restore any appropriate settings which have values in the property table
 /// </summary>
 public static void RestoreSettings(IFdoServiceLocator services, PropertyTable propertyTable)
 {
     var hcSettings = propertyTable.GetStringProperty(khomographconfiguration, null);
     if (hcSettings != null)
     {
         var hc = services.GetInstance<HomographConfiguration>();
         hc.PersistData = hcSettings;
     }
 }
Example #24
0
        public void Insert_Deleted()
        {
            IFdoServiceLocator servLoc = Cache.ServiceLocator;

            IScrBook book0 = servLoc.GetInstance <IScrBookFactory>().Create(1);

            m_scr.ScriptureBooksOS.Remove(book0);
            m_scr.ScriptureBooksOS.Insert(0, book0);
        }
Example #25
0
        /// <summary>
        /// Restore any appropriate settings which have values in the property table
        /// </summary>
        public static void RestoreSettings(IFdoServiceLocator services, PropertyTable propertyTable)
        {
            var hcSettings = propertyTable.GetStringProperty(khomographconfiguration, null);

            if (hcSettings != null)
            {
                var hc = services.GetInstance <HomographConfiguration>();
                hc.PersistData = hcSettings;
            }
        }
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Disable the vernacular spelling dictionary for all vernacular WSs.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        public static void DisableVernacularSpellingDictionary(FdoCache cache)
        {
            IFdoServiceLocator servloc = cache.ServiceLocator;
            var factory = servloc.GetInstance <ILgWritingSystemFactory>();

            foreach (IWritingSystem ws in cache.ServiceLocator.WritingSystems.VernacularWritingSystems)
            {
                ws.SpellCheckingId = "<None>";
            }
        }
Example #27
0
        public void CopyTo_NoItemsInEmptyItemListTest()
        {
            IFdoServiceLocator servLoc  = Cache.ServiceLocator;
            IScrBookFactory    bookFact = servLoc.GetInstance <IScrBookFactory>();

            IScrBook[] bookArray = new IScrBook[0];
            m_scr.ScriptureBooksOS.CopyTo(bookArray, 0);
            // This test makes sure that an exception is not thrown when the array is empty.
            // This fixes creating a new List<> when giving a FdoVector as the parameter.
        }
Example #28
0
        public void InsertIntoRefSequence_Uninitialized()
        {
            IFdoServiceLocator servLoc = Cache.ServiceLocator;
            ILangProject       lp      = Cache.LanguageProject;
            ILexEntry          le      = servLoc.GetInstance <ILexEntryFactory>().Create();

            var senseUninitialized = MockRepository.GenerateStub <ILexSense>();

            senseUninitialized.Stub(x => x.Hvo).Return((int)SpecialHVOValues.kHvoUninitializedObject);
            le.MainEntriesOrSensesRS.Insert(0, senseUninitialized);
        }
Example #29
0
        public void MoveTo_EmptyListTest()
        {
            IFdoServiceLocator servLoc  = Cache.ServiceLocator;
            IScrBookFactory    bookFact = servLoc.GetInstance <IScrBookFactory>();

            // Setup the source sequence using the scripture books sequence.
            IScrBook book0 = bookFact.Create(1);
            IScrBook book1 = bookFact.Create(2);
            IScrBook book2 = bookFact.Create(3);

            // Setup the target sequence so it's able to have items moved to it.
            IScrDraft targetSeq = servLoc.GetInstance <IScrDraftFactory>().Create("MoveTo_EmptyListTest");

            m_scr.ScriptureBooksOS.MoveTo(1, 2, targetSeq.BooksOS, 0);

            Assert.AreEqual(2, targetSeq.BooksOS.Count);
            Assert.AreEqual(1, m_scr.ScriptureBooksOS.Count);
            Assert.AreEqual(book1, targetSeq.BooksOS[0]);
            Assert.AreEqual(book2, targetSeq.BooksOS[1]);
        }
Example #30
0
        public void MoveTo_DestListLargerThenSrcTest()
        {
            IFdoServiceLocator servLoc  = Cache.ServiceLocator;
            IScrBookFactory    bookFact = servLoc.GetInstance <IScrBookFactory>();

            // Setup the source sequence using the scripture books sequence.
            IScrBook book0 = bookFact.Create(1);

            // Setup the target sequence so it's able to have items moved to it.
            IScrDraft targetSeq = servLoc.GetInstance <IScrDraftFactory>().Create("MoveTo_DestListLargerThenSrcTest");
            IScrBook  bookD0    = bookFact.Create(targetSeq.BooksOS, 1);
            IScrBook  bookD1    = bookFact.Create(targetSeq.BooksOS, 2);

            m_scr.ScriptureBooksOS.MoveTo(0, 0, targetSeq.BooksOS, 2);

            Assert.AreEqual(3, targetSeq.BooksOS.Count);
            Assert.AreEqual(0, m_scr.ScriptureBooksOS.Count);
            Assert.AreEqual(bookD0, targetSeq.BooksOS[0]);
            Assert.AreEqual(bookD1, targetSeq.BooksOS[1]);
            Assert.AreEqual(book0, targetSeq.BooksOS[2]);
        }
Example #31
0
        public void ContainsMethodTests()
        {
            IFdoServiceLocator servLoc = Cache.ServiceLocator;
            ILangProject       lp      = Cache.LanguageProject;
            ILexDb             lexDb   = lp.LexDbOA;
            ILexEntry          le      = servLoc.GetInstance <ILexEntryFactory>().Create();

            // FdoReferenceCollection
            Assert.IsFalse(lexDb.LexicalFormIndexRC.Contains(le));
            lexDb.LexicalFormIndexRC.Add(le);
            Assert.IsTrue(lexDb.LexicalFormIndexRC.Contains(le));
            lexDb.LexicalFormIndexRC.Remove(le);
        }
Example #32
0
        public void CopyTo_OneItemInOneItemListTest()
        {
            IFdoServiceLocator servLoc  = Cache.ServiceLocator;
            IScrBookFactory    bookFact = servLoc.GetInstance <IScrBookFactory>();

            // Setup the source sequence using the scripture books sequence.
            IScrBook book0 = bookFact.Create(1);

            IScrBook[] bookArray = new IScrBook[1];
            m_scr.ScriptureBooksOS.CopyTo(bookArray, 0);

            Assert.AreEqual(book0, bookArray[0]);
        }
Example #33
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ParseFiler"/> class.
        /// </summary>
        /// <param name="cache">The cache.</param>
        /// <param name="taskUpdateHandler">The task update handler.</param>
        /// <param name="idleQueue">The idle queue.</param>
        /// <param name="parserAgent">The parser agent.</param>
        public ParseFiler(FdoCache cache, Action <TaskReport> taskUpdateHandler, IdleQueue idleQueue, ICmAgent parserAgent)
        {
            Debug.Assert(cache != null);
            Debug.Assert(taskUpdateHandler != null);
            Debug.Assert(idleQueue != null);
            Debug.Assert(parserAgent != null);

            m_cache             = cache;
            m_taskUpdateHandler = taskUpdateHandler;
            m_idleQueue         = idleQueue;
            m_parserAgent       = parserAgent;
            m_workQueue         = new Queue <WordformUpdateWork>();
            m_syncRoot          = new object();

            IFdoServiceLocator servLoc = cache.ServiceLocator;

            m_analysisFactory          = servLoc.GetInstance <IWfiAnalysisFactory>();
            m_mbFactory                = servLoc.GetInstance <IWfiMorphBundleFactory>();
            m_baseAnnotationRepository = servLoc.GetInstance <ICmBaseAnnotationRepository>();
            m_baseAnnotationFactory    = servLoc.GetInstance <ICmBaseAnnotationFactory>();
            m_userAgent                = m_cache.LanguageProject.DefaultUserAgent;
        }
Example #34
0
        public void CopyTo_RefSeqToRefSeq()
        {
            IFdoServiceLocator servLoc = Cache.ServiceLocator;
            ILangProject       lp      = Cache.LanguageProject;
            ILexEntry          le1     = servLoc.GetInstance <ILexEntryFactory>().Create();
            ILexSense          sense1  = servLoc.GetInstance <ILexSenseFactory>().Create();

            le1.SensesOS.Add(sense1);
            le1.MainEntriesOrSensesRS.Add(sense1);
            ILexSense sense2 = servLoc.GetInstance <ILexSenseFactory>().Create();

            le1.SensesOS.Add(sense2);
            le1.MainEntriesOrSensesRS.Add(sense2);

            ILexEntry le2 = servLoc.GetInstance <ILexEntryFactory>().Create();

            le1.MainEntriesOrSensesRS.CopyTo(le2.MainEntriesOrSensesRS, 0);

            Assert.AreEqual(2, le2.MainEntriesOrSensesRS.Count);
            Assert.AreEqual(sense1, le2.MainEntriesOrSensesRS[0]);
            Assert.AreEqual(sense2, le2.MainEntriesOrSensesRS[1]);
        }
Example #35
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Create test data for tests.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		protected override void CreateTestData()
		{
			m_servloc = Cache.ServiceLocator;
			m_text = AddInterlinearTextToLangProj("My Interlinear Text");
			m_stTextPara = AddParaToInterlinearTextContents(m_text, "Here is a sentence I can chart.");
			m_stText = m_text.ContentsOA;
			m_tssFact = Cache.TsStrFactory;
			m_rowFact = m_servloc.GetInstance<IConstChartRowFactory>();
			m_wordGrpFact = m_servloc.GetInstance<IConstChartWordGroupFactory>();
			m_possFact = m_servloc.GetInstance<ICmPossibilityFactory>();
			m_wfiFact = m_servloc.GetInstance<IWfiWordformFactory>();
			m_mtMrkrFact = m_servloc.GetInstance<IConstChartMovedTextMarkerFactory>();
			m_clsMrkrFact = m_servloc.GetInstance<IConstChartClauseMarkerFactory>();
		}
Example #36
0
		internal GhostParentHelper(IFdoServiceLocator services, int parentClsid, int flidOwning)
		{
			m_services = services;
			m_parentClsid = parentClsid;
			m_flidOwning = flidOwning;
			var mdc = m_services.GetInstance<IFwMetaDataCacheManaged>();
			TargetClass = mdc.GetDstClsId(flidOwning);
			switch ((CellarPropertyType)mdc.GetFieldType(flidOwning))
			{
				case CellarPropertyType.OwningAtomic:
					m_indexToCreate = -2;
					break;
				case CellarPropertyType.OwningCollection:
					m_indexToCreate = -1;
					break;
				case CellarPropertyType.OwningSequence:
					m_indexToCreate = 0;
					break;
				default:
					throw new InvalidOperationException("can only create objects in owning properties");
			}
		}
Example #37
0
		/// <summary>
		/// Make a slot which can be identified as the specified type.
		/// For this to be true, the slot must have an msa, owned by a LexEntry, which owns a form, which has
		/// the required type.
		/// </summary>
		IMoInflAffixSlot MakeSlot(IFdoServiceLocator services, IFdoOwningCollection<IMoInflAffixSlot> dest, Guid slotType)
		{
			var entry = services.GetInstance<ILexEntryFactory>().Create();
			var form = services.GetInstance<IMoAffixAllomorphFactory>().Create();
			entry.LexemeFormOA = form;
			form.MorphTypeRA = services.GetInstance<IMoMorphTypeRepository>().GetObject(slotType);
			var msa = services.GetInstance<IMoInflAffMsaFactory>().Create();
			entry.MorphoSyntaxAnalysesOC.Add(msa);
			var slot = services.GetInstance<IMoInflAffixSlotFactory>().Create();
			dest.Add(slot);
			msa.SlotsRC.Add(slot);
			// slot.Affixes.Add(msa); does not add it!
			return slot;
		}
Example #38
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Loads all the lexical entries from the specified service locator into a collection
		/// of PaLexEntry objects.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		internal static List<PaLexEntry> GetAll(IFdoServiceLocator svcloc)
		{
			return svcloc.GetInstance<ILexEntryRepository>().AllInstances()
				.Where(lx => lx.LexemeFormOA != null && lx.LexemeFormOA.Form.StringCount > 0)
				.Select(lx => new PaLexEntry(lx)).ToList();
		}
 /// <summary>
 /// Save any appropriate settings to the property table
 /// </summary>
 public static void SaveSettings(IFdoServiceLocator services, PropertyTable propertyTable)
 {
     var hc = services.GetInstance<HomographConfiguration>();
     propertyTable.SetProperty(khomographconfiguration, hc.PersistData);
 }