public ParallelBibleInfo GetParallelBibleInfo( string baseModuleShortName, string parallelModuleShortName, BibleTranslationDifferences baseBookTranslationDifferences, BibleTranslationDifferences parallelBookTranslationDifferences, bool refreshCache = false) { var key = GetKey(baseModuleShortName, parallelModuleShortName); if (refreshCache || !_cache.TryGetValue(key, out ParallelBibleInfo result)) { result = new ParallelBibleInfo(); if (baseModuleShortName.ToLower() != parallelModuleShortName.ToLower()) { var verseFactory = new BibleTranslationDifferencesBaseVersesFormula.VerseFactory((s, bookIndex) => { var verseEntry = _stringParser.TryGetVerse(s, 0); if (verseEntry.VersePointerFound) { return(verseEntry.VersePointer.ToModuleVersePointer(false, bookIndex)); } else { throw new NotSupportedException($"Verse formula is invalid: {s}"); } }); var baseTranslationDifferencesEx = new BibleTranslationDifferencesEx(baseBookTranslationDifferences, verseFactory); var parallelTranslationDifferencesEx = new BibleTranslationDifferencesEx(parallelBookTranslationDifferences, verseFactory); ProcessForBaseBookVerses(baseTranslationDifferencesEx, parallelTranslationDifferencesEx, result); ProcessForParallelBookVerses(baseTranslationDifferencesEx, parallelTranslationDifferencesEx, result); } lock (_locker) { if (!_cache.ContainsKey(key)) { _cache.Add(key, result); } else { _cache[key] = result; } } } return(result); }
public BibleTranslationDifferencesEx( BibleTranslationDifferences translationDifferences, BibleTranslationDifferencesBaseVersesFormula.VerseFactory verseFactory) { BibleVersesDifferences = new ParallelBibleInfo(); foreach (var bookDifferences in translationDifferences.BookDifferences) { BibleVersesDifferences.Add(bookDifferences.BookIndex, new ModuleVersePointersComparisonTable()); foreach (var bookDifference in bookDifferences.Differences) { ProcessBookDifference(bookDifferences.BookIndex, bookDifference, verseFactory); } } }
private void ProcessBookDifference( int bookIndex, BibleBookDifference bookDifference, BibleTranslationDifferencesBaseVersesFormula.VerseFactory verseFactory) { int?valueVersesCount = string.IsNullOrEmpty(bookDifference.ValueVersesCount) ? (int?)null : int.Parse(bookDifference.ValueVersesCount); var baseVersesFormula = new BibleTranslationDifferencesBaseVersesFormula( bookIndex, bookDifference.BaseVerses, bookDifference.ParallelVerses, bookDifference.CorrespondenceType, bookDifference.SkipCheck, bookDifference.EmptyVerse, verseFactory); var parallelVersesFormula = new BibleTranslationDifferencesParallelVersesFormula( bookDifference.ParallelVerses, baseVersesFormula, bookDifference.CorrespondenceType, valueVersesCount, bookDifference.SkipCheck, bookDifference.EmptyVerse); ModuleVersePointer prevVerse = null; foreach (var verse in baseVersesFormula.GetAllVerses()) { var parallelVerses = new ComparisonVersesInfo(parallelVersesFormula.GetParallelVerses(verse, prevVerse)); BibleVersesDifferences[bookIndex].Add(verse, parallelVerses); prevVerse = parallelVerses.Last(); } }