/// <summary> /// Provides access to the ProcessVersLine method /// </summary> public static void ProcessVersLine(this ScrVers scrVers, string versLine) { Versification internalVers = (Versification)ReflectionHelper.GetProperty(scrVers, "VersInfo"); ReflectionHelper.CallMethodWithThrow(Versification.Table.Implementation, "ProcessVersLine", versLine, "testfile", ScrVersType.Unknown, "", internalVers); }
public void ParseMappingLine_CompareBaseToCustomized() { Versification vers2 = ScrVersReflectionHelper.CreateClonedVers(versification.VersInfo, versification.Name + "-monkey"); ScrVers versification2 = new ScrVers(vers2); versification.ParseChapterVerseLine( "ACT 1:26 2:47 3:26 4:37 5:42 6:15 7:60 8:40 9:43 10:48 11:30 12:25 13:52 14:28 15:41 16:40 17:34 18:28 19:41 20:38 21:40 22:30 23:35 24:27 25:27 26:32 27:44 28:31"); versification2.ParseChapterVerseLine( "ACT 1:26 2:47 3:26 4:37 5:42 6:15 7:60 8:40 9:43 10:48 11:30 12:25 13:52 14:28 15:41 16:40 17:34 18:28 19:41 20:38 21:40 22:30 23:35 24:27 25:27 26:32 27:44 28:31"); versification2.ParseMappingLine("ACT 19:41 = ACT 19:40"); versification.ParseMappingLine("ACT 19:41 = ACT 19:40"); // Even tho we have both vers 40 and 41 mapped to the same verse, doing a conversion between the // two versification should not cause the original distinction to be lost if both versifications are // based on the same original versification. VerseRef vref = new VerseRef("ACT 19:40", versification); versification2.ChangeVersification(ref vref); Assert.AreEqual(new VerseRef("ACT 19:40", versification2), vref); vref = new VerseRef("ACT 19:41", versification); versification2.ChangeVersification(ref vref); Assert.AreEqual(new VerseRef("ACT 19:41", versification2), vref); }
/// <summary> /// Provides access to the ParseMappingLine method /// </summary> public static void ParseMappingLine(this ScrVers scrVers, string mappingLine) { Versification internalVers = scrVers.VersInfo; ReflectionHelper.CallMethodWithThrow(Versification.Table.Implementation, "ProcessVersLine", mappingLine, "testfile", ScrVersType.Unknown, "", internalVers); }
/// <summary> /// Provides access to the ParseVerseSegmentsLine method /// </summary> public static void ParseVerseSegmentsLine(this ScrVers scrVers, string segmentsLine, string fileName = "testfile") { Versification internalVers = (Versification)ReflectionHelper.GetProperty(scrVers, "VersInfo"); ReflectionHelper.CallMethodWithThrow(Versification.Table.Implementation, "ProcessVersLine", "#! " + segmentsLine, fileName, ScrVersType.Unknown, "", internalVers); }
/// <summary> /// Clears all information from the internal versification for testing on a clean slate /// </summary> public static void ClearAllInfo(this ScrVers scrVers) { Versification internalVers = (Versification)ReflectionHelper.GetProperty(scrVers, "VersInfo"); ((List <int[]>)ReflectionHelper.GetField(internalVers, "bookList")).Clear(); scrVers.ClearExcludedVerses(); ((Dictionary <int, string[]>)ReflectionHelper.GetField(internalVers, "verseSegments")).Clear(); object mappings = ReflectionHelper.GetField(internalVers, "mappings"); ReflectionHelper.CallMethodWithThrow(mappings, "Clear"); }
public ProjectSettingsViewModel(Project project) { Project = project; WsModel = new WritingSystemSetupModel(project.WritingSystem) { CurrentDefaultFontName = project.FontFamily, CurrentDefaultFontSize = project.FontSizeInPoints, CurrentRightToLeftScript = project.RightToLeftScript }; RecordingProjectName = project.Name; AudioStockNumber = project.AudioStockNumber; BundlePath = project.OriginalBundlePath; ParatextProjectName = project.ParatextProjectName; IsLiveParatextProject = project.IsLiveParatextProject; LanguageName = project.LanguageName; IsoCode = project.LanguageIsoCode; PublicationId = project.Id; PublicationName = project.PublicationName; Versification = project.Versification; m_chapterAnnouncementStyle = project.ChapterAnnouncementStyle; SkipChapterAnnouncementForFirstChapter = project.SkipChapterAnnouncementForFirstChapter; SkipChapterAnnouncementForSingleChapterBooks = SkipChapterAnnouncementForFirstChapter || project.SkipChapterAnnouncementForSingleChapterBooks; var block = project.IncludedBooks.SelectMany(book => book.GetScriptBlocks().Where(b => b.ContainsVerseNumber)).FirstOrDefault(); if (block != null) { SampleText = block.GetText(false); } var multiChapterBooks = project.IncludedBooks.Where(book => Versification.GetLastChapter(BCVRef.BookToNumber(book.BookId)) > 1); foreach (var book in multiChapterBooks) { var chapterBlocks = book.GetScriptBlocks().Where(b => b.IsChapterAnnouncement).Take(2).ToList(); if (chapterBlocks.Any()) { m_exampleFirstChapterLabel = chapterBlocks.First().BlockElements.OfType <ScriptText>().First().Content; if (chapterBlocks.Count > 1) { m_exampleChapterLabel = chapterBlocks[1].BlockElements.OfType <ScriptText>().First().Content; m_exampleChapterNumber = chapterBlocks[1].ChapterNumber; m_exampleMultiChapterBookId = book.BookId; var title = book.GetScriptBlocks().FirstOrDefault(b => b.StyleTag == "mt"); if (title != null) { m_exampleMultiChapterBookTitle = title.GetText(false); } } break; } } var singleChapterBook = project.IncludedBooks.FirstOrDefault(book => Versification.GetLastChapter(BCVRef.BookToNumber(book.BookId)) == 1); if (singleChapterBook != null) { var chapterBlock = singleChapterBook.GetScriptBlocks().FirstOrDefault(b => b.IsChapterAnnouncement); if (chapterBlock != null) { m_exampleSingleChapterLabel = chapterBlock.BlockElements.OfType <ScriptText>().First().Content; } m_exampleSingleChapterBookId = singleChapterBook.BookId; var title = singleChapterBook.GetScriptBlocks().FirstOrDefault(b => b.StyleTag == "mt"); if (title != null) { m_exampleSingleChapterBookTitle = title.GetText(false); } } }
/// <summary> /// Provides access to the excludedVerses field /// </summary> public static HashSet <int> excludedVerses(this ScrVers scrVers) { Versification internalVers = (Versification)ReflectionHelper.GetProperty(scrVers, "VersInfo"); return((HashSet <int>)ReflectionHelper.GetField(internalVers, "excludedVerses")); }
/// <summary> /// Provides access to the bookList field /// </summary> public static List <int[]> bookList(this ScrVers scrVers) { Versification internalVers = (Versification)ReflectionHelper.GetProperty(scrVers, "VersInfo"); return((List <int[]>)ReflectionHelper.GetField(internalVers, "bookList")); }
public static Versification CreateClonedVers(Versification orig, string newName) { return((Versification)ReflectionHelper.CreateClassInstance(Assembly.Load("SIL.Scripture"), "SIL.Scripture.Versification", new object[] { orig, newName, "" })); }
/// <summary> /// Clears all verse segments information from the internal versification for testing on a clean slate /// </summary> public static void ClearVerseSegments(this ScrVers scrVers) { Versification internalVers = (Versification)ReflectionHelper.GetProperty(scrVers, "VersInfo"); ((Dictionary <int, string[]>)ReflectionHelper.GetField(internalVers, "verseSegments")).Clear(); }
/// <summary> /// Clears all excluded verse information from the internal versification for testing /// on a clean slate /// </summary> public static void ClearExcludedVerses(this ScrVers scrVers) { Versification internalVers = (Versification)ReflectionHelper.GetProperty(scrVers, "VersInfo"); ((HashSet <int>)ReflectionHelper.GetField(internalVers, "excludedVerses")).Clear(); }
/// <summary> /// Internal constructor for creating a ScrVers directly with a versification /// </summary> internal ScrVers(Versification versInfo) { this.versInfo = versInfo; type = versInfo.Type; }