public ConcDecorator(ISilDataAccessManaged domainDataByFlid, XmlNode configurationNode, IFdoServiceLocator services) : base(domainDataByFlid) { m_services = services; SetOverrideMdc(new ConcMdc(MetaDataCache as IFwMetaDataCacheManaged)); }
public ConvertMongoToFdoCustomField(FdoCache cache, ILogger logger) { this.cache = cache; servLoc = cache.ServiceLocator; fdoMetaData = (IFwMetaDataCacheManaged)cache.MetaDataCacheAccessor; this.logger = logger; }
public InterestingTextsDecorator(ISilDataAccessManaged domainDataByFlid, XmlNode configurationNode, IFdoServiceLocator services) : base(domainDataByFlid) { SetOverrideMdc(new InterestingTextsMdc(base.MetaDataCache as IFwMetaDataCacheManaged)); m_services = services; }
/// <summary> /// Returns GPHs for the four properties we currently know about, or null if not a known property that has ghosts. /// </summary> /// <param name="services"></param> /// <param name="classDotMethod"></param> /// <returns></returns> public static GhostParentHelper CreateIfPossible(IFdoServiceLocator services, string classDotMethod) { switch (classDotMethod) { case "LexDb.AllPossiblePronunciations": return(new GhostParentHelper(services, LexEntryTags.kClassId, LexEntryTags.kflidPronunciations)); case "LexDb.AllPossibleAllomorphs": return(new GphAllPossibleAllomorphs(services, LexEntryTags.kClassId, LexEntryTags.kflidAlternateForms)); case "LexDb.AllExampleSentenceTargets": return(new GhostParentHelper(services, LexSenseTags.kClassId, LexSenseTags.kflidExamples)); case "LexDb.AllExampleTranslationTargets": return(new GhostParentHelper(services, LexExampleSentenceTags.kClassId, LexExampleSentenceTags.kflidTranslations)); case "LexDb.AllComplexEntryRefPropertyTargets": return(new GphComplexEntries(services)); case "LexDb.AllVariantEntryRefPropertyTargets": return(new GphVariants(services)); default: return(null); } }
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"); } }
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)); }
protected override void DoRun(ILfProject project) { // TODO: These checks might be overkill; consider removing some of them Logger.Debug("FdoToMongo: starting"); FwProject fwProject = project.FieldWorksProject; if (fwProject == null) { Logger.Error("Can't find FieldWorks project {0}", project.ProjectCode); return; } Logger.Debug("FdoToMongo: getting cache"); _cache = fwProject.Cache; if (_cache == null) { Logger.Error("Can't find cache for FieldWorks project {0}", project.ProjectCode); return; } Logger.Debug("FdoToMongo: serviceLocator"); _servLoc = _cache.ServiceLocator; if (_servLoc == null) { Logger.Error("Can't find service locator for FieldWorks project {0}", project.ProjectCode); return; } _lexiconConverter = new ConvertFdoToMongoLexicon(project, Logger, _connection); _lexiconConverter.RunConversion(); }
/// <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); }
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); }
public DiscourseTestHelper(FdoCache cache) { m_cache = cache; #region Load Factories and Repositories m_servLoc = m_cache.ServiceLocator; m_tsf = cache.TsStrFactory; m_wAnalysisFact = m_servLoc.GetInstance <IWfiAnalysisFactory>(); m_wGlossFact = m_servLoc.GetInstance <IWfiGlossFactory>(); m_rowFact = m_servLoc.GetInstance <IConstChartRowFactory>(); m_wordGrpFact = m_servLoc.GetInstance <IConstChartWordGroupFactory>(); m_ccTagFact = m_servLoc.GetInstance <IConstChartTagFactory>(); m_mtmFact = m_servLoc.GetInstance <IConstChartMovedTextMarkerFactory>(); m_clauseMrkrFact = m_servLoc.GetInstance <IConstChartClauseMarkerFactory>(); m_partRepo = m_servLoc.GetInstance <IConstituentChartCellPartRepository>(); m_rowRepo = m_servLoc.GetInstance <IConstChartRowRepository>(); #endregion m_text = m_servLoc.GetInstance <ITextFactory>().Create(); //Cache.LangProject.TextsOC.Add(m_text); m_stText = m_servLoc.GetInstance <IStTextFactory>().Create(); m_text.ContentsOA = m_stText; m_allOccurrences = new Dictionary <IStTxtPara, AnalysisOccurrence[]>(); m_firstPara = MakeParagraph(); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Initializes a new instance of the <see cref="TeKeyTermsInit"/> class. /// </summary> /// ------------------------------------------------------------------------------------ protected TeKeyTermsInit(IScripture scr, IApp app) { m_scr = scr; m_app = app; m_wsf = scr.Cache.LanguageWritingSystemFactoryAccessor; m_servLoc = scr.Cache.ServiceLocator; }
/// <summary> /// Returns GPHs for the four properties we currently know about. /// </summary> /// <param name="services"></param> /// <param name="classDotMethod"></param> /// <returns></returns> public static GhostParentHelper Create(IFdoServiceLocator services, string classDotMethod) { var result = CreateIfPossible(services, classDotMethod); if (result == null) throw new ArgumentException("Unexpected field request to GhostParentHelper.Create", "classDotMethod"); return result; }
/// ------------------------------------------------------------------------------------ /// <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); } } } } }
/// <summary> /// Make one. This variant is used in testing (to plug in a known logic class). /// </summary> internal ConstituentChart(FdoCache cache, ConstituentChartLogic logic) { m_cache = cache; m_serviceLocator = m_cache.ServiceLocator; m_logic = logic; BuildUIComponents(); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Initializes a new instance of the <see cref="CopyObject<TTopLevel>"/> class. /// </summary> /// <param name="cache">The cache.</param> /// <param name="topLevelOwnerFunct">The delegate used for adding the created object to /// an owner.</param> /// ------------------------------------------------------------------------------------ private CopyObject(FdoCache cache, CopiedOwner <TTopLevel> topLevelOwnerFunct) { m_cache = cache; m_servLoc = m_cache.ServiceLocator; m_sda = m_cache.DomainDataByFlid; m_mdc = m_cache.ServiceLocator.GetInstance <IFwMetaDataCacheManaged>(); m_topLevelOwnerFunct = topLevelOwnerFunct; }
public void Insert_Null() { IFdoServiceLocator servLoc = Cache.ServiceLocator; IScrBook book0 = servLoc.GetInstance <IScrBookFactory>().Create(1); m_scr.ScriptureBooksOS.Insert(0, null); }
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> /// 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(); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Creates the test data. /// </summary> /// ------------------------------------------------------------------------------------ protected override void CreateTestData() { m_servLoc = Cache.ServiceLocator; m_wsf = Cache.WritingSystemFactory; m_ws_en = m_wsf.GetWsFromStr("en"); m_ws_fr = m_wsf.GetWsFromStr("fr"); CreateTestText(); }
/// <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> /// 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> /// 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(); }
/// <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(); }
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); }
/// ------------------------------------------------------------------------------------ /// <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>"; } }
/// <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> /// Returns GPHs for the four properties we currently know about. /// </summary> /// <param name="services"></param> /// <param name="classDotMethod"></param> /// <returns></returns> public static GhostParentHelper Create(IFdoServiceLocator services, string classDotMethod) { var result = CreateIfPossible(services, classDotMethod); if (result == null) { throw new ArgumentException("Unexpected field request to GhostParentHelper.Create", "classDotMethod"); } return(result); }
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. }
/// ------------------------------------------------------------------------------------ /// <summary> /// Loads all the lexical entries from the specified service locator into a collection /// of PaLexEntry objects and returns the collection in a serialized list. /// </summary> /// ------------------------------------------------------------------------------------ internal static string GetAllAsXml(IFdoServiceLocator svcloc) { try { return(XmlSerializationHelper.SerializeToString(GetAll(svcloc))); } catch { return(null); } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Initializes a new instance of the <see cref="TeScrNoteCategoriesInit"/> class. /// </summary> /// <param name="progressDlg">The progress dialog.</param> /// <param name="scr">The scripture object.</param> /// <param name="categories">The categories.</param> /// ------------------------------------------------------------------------------------ protected TeScrNoteCategoriesInit(IProgress progressDlg, IScripture scr, XmlNode categories) { m_scr = scr; m_servLoc = scr.Cache.ServiceLocator; m_progressDlg = progressDlg; m_categories = categories; m_defUserWs = m_servLoc.WritingSystemManager.UserWs; m_wsId = m_servLoc.WritingSystemManager.UserWritingSystem.Id; m_fallbackUserWsId = WritingSystemServices.FallbackUserWsId; }
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); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Loads all the lexical entries from the specified service locator into a collection /// of PaLexEntry objects and returns the collection in a serialized list. /// </summary> /// ------------------------------------------------------------------------------------ internal static string GetAllAsXml(IFdoServiceLocator svcloc) { try { return XmlSerializationHelper.SerializeToString(GetAll(svcloc)); } catch { return null; } }
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); }
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. }
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); }
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); }
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]); }
/// ------------------------------------------------------------------------------------ /// <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>(); }
/// ------------------------------------------------------------------------------------ /// <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>(); }
/// ------------------------------------------------------------------------------------ private PaWritingSystem(IWritingSystem lgws, IFdoServiceLocator svcloc, bool isVern, bool isAnal) { Id = lgws.Id; DisplayName = lgws.DisplayLabel; LanguageName = lgws.LanguageName; Abbreviation = lgws.Abbreviation; IcuLocale = lgws.IcuLocale; Hvo = lgws.Handle; DefaultFontName = lgws.DefaultFontName; IsVernacular = isVern; IsAnalysis = isAnal; IsDefaultAnalysis = (lgws == svcloc.WritingSystems.DefaultAnalysisWritingSystem); IsDefaultVernacular = (lgws == svcloc.WritingSystems.DefaultVernacularWritingSystem); IsDefaultPronunciation = (lgws == svcloc.WritingSystems.DefaultPronunciationWritingSystem); }
/// ------------------------------------------------------------------------------------ private PaMultiString(ITsMultiString msa, IFdoServiceLocator svcloc) { Texts = new List<string>(msa.StringCount); WsIds = new List<string>(msa.StringCount); for (int i = 0; i < msa.StringCount; i++) { int hvoWs; ITsString tss = msa.GetStringFromIndex(i, out hvoWs); Texts.Add(tss.Text); // hvoWs should *always* be found in AllWritingSystems. var ws = svcloc.WritingSystems.AllWritingSystems.SingleOrDefault(w => w.Handle == hvoWs); WsIds.Add(ws == null ? null : ws.Id); } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Loads all the writing systems from the specified service locator into a /// collection of PaWritingSystem objects. /// </summary> /// ------------------------------------------------------------------------------------ internal static string GetWritingSystemsAsXml(IFdoServiceLocator svcloc) { var wsList = new List<PaWritingSystem>(); foreach (var ws in svcloc.WritingSystems.AllWritingSystems) { if (!wsList.Any(w => w.Id == ws.Id)) { bool isVern = (svcloc.WritingSystems.VernacularWritingSystems.Contains(ws)); bool isAnal = (svcloc.WritingSystems.AnalysisWritingSystems.Contains(ws)); wsList.Add(new PaWritingSystem(ws, svcloc, isVern, isAnal)); } } return XmlSerializationHelper.SerializeToString(wsList); }
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; }
/// <summary> /// Returns GPHs for the four properties we currently know about, or null if not a known property that has ghosts. /// </summary> /// <param name="services"></param> /// <param name="classDotMethod"></param> /// <returns></returns> public static GhostParentHelper CreateIfPossible(IFdoServiceLocator services, string classDotMethod) { switch (classDotMethod) { case "LexDb.AllPossiblePronunciations": return new GhostParentHelper(services, LexEntryTags.kClassId, LexEntryTags.kflidPronunciations); case "LexDb.AllPossibleAllomorphs": return new GphAllPossibleAllomorphs(services, LexEntryTags.kClassId, LexEntryTags.kflidAlternateForms); case "LexDb.AllExampleSentenceTargets": return new GhostParentHelper(services, LexSenseTags.kClassId, LexSenseTags.kflidExamples); case "LexDb.AllExampleTranslationTargets": return new GhostParentHelper(services, LexExampleSentenceTags.kClassId, LexExampleSentenceTags.kflidTranslations); case "LexDb.AllComplexEntryRefPropertyTargets": return new GphComplexEntries(services); case "LexDb.AllVariantEntryRefPropertyTargets": return new GphVariants(services); default: return null; } }
internal static GhostParentHelper GetGhostHelper(IFdoServiceLocator locator, XmlNode colSpec) { string classDotField = XmlUtils.GetOptionalAttributeValue(colSpec, "ghostListField"); if (classDotField == null) return null; return GhostParentHelper.Create(locator, classDotField); }
/// <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); }
internal GphVariants(IFdoServiceLocator services) : base(services, LexEntryTags.kClassId, LexEntryTags.kflidEntryRefs) { }
internal GphComplexEntries(IFdoServiceLocator services) : base(services, LexEntryTags.kClassId, LexEntryTags.kflidEntryRefs) { }
internal GphAllPossibleAllomorphs(IFdoServiceLocator services, int parentClsid, int flidOwning) : base(services, parentClsid, flidOwning) { }
/// <summary> /// Return a ghost parent helper based on a flid, or null if this flid does not need one. /// </summary> public static GhostParentHelper CreateIfPossible(IFdoServiceLocator services, int flid) { var mdc = services.MetaDataCache; return CreateIfPossible(services, mdc.GetOwnClsName(flid) + "." + mdc.GetFieldName(flid)); }
/// <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; }
/// ------------------------------------------------------------------------------------ /// <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(); }
/// ------------------------------------------------------------------------------------ public static PaMultiString Create(ITsMultiString msa, IFdoServiceLocator svcloc) { return (msa == null || msa.StringCount == 0 ? null : new PaMultiString(msa, svcloc)); }
public RespellingSda(ISilDataAccessManaged domainDataByFlid, XmlNode configurationNode, IFdoServiceLocator services) : base(domainDataByFlid, configurationNode, services) { SetOverrideMdc(new RespellingMdc(MetaDataCache as IFwMetaDataCacheManaged)); }
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"); } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Initialize the FDO cache and open database /// </summary> /// <remarks>This method is called before each test</remarks> /// ------------------------------------------------------------------------------------ public override void TestSetup() { base.TestSetup(); m_servloc = Cache.ServiceLocator; }