/// ------------------------------------------------------------------------------------ /// <summary> /// Reads the current TE scripture project. /// </summary> /// ------------------------------------------------------------------------------------ private List <TextTokenSubstring> ReadTEScripture() { IChecksDataSource scrDataSource = ReflectionHelper.CreateObject("ScrFDO.dll", "SIL.FieldWorks.FDO.Scripture.ScrChecksDataSource", new object[] { m_cache }) as IChecksDataSource; if (scrDataSource == null) { return(null); } Assembly asm = Assembly.LoadFile(m_scrChecksDllFile); if (asm == null) { return(null); } Type type = asm.GetType("SILUBS.ScriptureChecks." + m_checkToRun); IScrCheckInventory scrCharInventoryBldr = Activator.CreateInstance(type, scrDataSource) as IScrCheckInventory; if (scrCharInventoryBldr == null) { return(null); } List <ITextToken> tokens = new List <ITextToken>(); IScripture scr = m_cache.LangProject.TranslatedScriptureOA; if (scr == null || scr.ScriptureBooksOS.Count == 0) { return(null); } foreach (IScrBook book in scr.ScriptureBooksOS) { if (scrDataSource.GetText(book.CanonicalNum, 0)) { tokens.AddRange(scrDataSource.TextTokens()); } } foreach (KeyValuePair <string, string> kvp in m_chkParams) { scrDataSource.SetParameterValue(kvp.Key, kvp.Value); } scrDataSource.SetParameterValue("PreferredLocale", string.Empty); if (tokens.Count == 0) { return(null); } return(GetTokenSubstrings(scrCharInventoryBldr, tokens)); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Gets the token substrings. /// </summary> /// <param name="inventory">The inventory used to parse the tokens.</param> /// <param name="tokens">The tokens (runs of text).</param> /// ------------------------------------------------------------------------------------ private List <TextTokenSubstring> GetTokenSubstrings(IScrCheckInventory inventory, List <ITextToken> tokens) { List <TextTokenSubstring> list = inventory.GetReferences(tokens, string.Empty); if (m_listValidator != null) { m_listValidator(list); } return(list); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Gets the references. /// </summary> /// <returns></returns> /// ------------------------------------------------------------------------------------ public List <TextTokenSubstring> GetReferences() { try { Assembly asm = Assembly.LoadFile(m_scrChecksDllFile); Type type = asm.GetType("SILUBS.ScriptureChecks." + m_scrCheck); IScrCheckInventory scrCharInventoryBldr = Activator.CreateInstance(type, this) as IScrCheckInventory; return(scrCharInventoryBldr.GetReferences(m_tftList, string.Empty)); } catch { return(null); } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Gets the references. /// </summary> /// <returns></returns> /// ------------------------------------------------------------------------------------ public List <TextTokenSubstring> GetReferences() { try { // If this whole valid characters area wasn't such a mess I'd move this bit into a unit // testable chunk to make sure the reflection didn't break again. If this breaks again // maybe it will encourage us to fix the whole mess. -jn 7/2020 Assembly asm = Assembly.LoadFile(m_scrChecksDllFile); Type type = asm.GetType("SILUBS.ScriptureChecks." + m_scrCheck); IScrCheckInventory scrCharInventoryBldr = Activator.CreateInstance(type, this) as IScrCheckInventory; return(scrCharInventoryBldr.GetReferences(m_tftList, string.Empty)); } catch { return(null); } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Reads the current TE scripture project. /// </summary> /// ------------------------------------------------------------------------------------ private List <TextTokenSubstring> ReadTEScripture() { var scrDataSource = new ScrChecksDataSource(m_cache, ResourceHelper.GetResourceString("kstidPunctCheckWhitespaceChar"), FwDirectoryFinder.LegacyWordformingCharOverridesFile, FwDirectoryFinder.TeStylesPath); scrDataSource.LoadException += scrDataSource_LoadException; IScrCheckInventory scrCharInventoryBldr = CreateScrCharInventoryBldr(FwDirectoryFinder.BasicEditorialChecksDll, scrDataSource, m_checkToRun == CheckType.Punctuation ? "SILUBS.ScriptureChecks.PunctuationCheck" : "SILUBS.ScriptureChecks.CharactersCheck"); var tokens = new List <ITextToken>(); var scr = m_cache.LangProject.TranslatedScriptureOA; if (scr == null || scr.ScriptureBooksOS.Count == 0) { return(null); } foreach (var book in scr.ScriptureBooksOS) { if (scrDataSource.GetText(book.CanonicalNum, 0)) { tokens.AddRange(scrDataSource.TextTokens()); } } foreach (KeyValuePair <string, string> kvp in m_chkParams) { scrDataSource.SetParameterValue(kvp.Key, kvp.Value); } scrDataSource.SetParameterValue("PreferredLocale", string.Empty); return(tokens.Count == 0 ? null : GetTokenSubstrings(scrCharInventoryBldr, tokens)); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Gets the token substrings. /// </summary> /// <param name="inventory">The inventory used to parse the tokens.</param> /// <param name="tokens">The tokens (runs of text).</param> /// ------------------------------------------------------------------------------------ private List<TextTokenSubstring> GetTokenSubstrings(IScrCheckInventory inventory, List<ITextToken> tokens) { List<TextTokenSubstring> list = inventory.GetReferences(tokens, string.Empty); if (m_listValidator != null) m_listValidator(list); return list; }