public List <ModuleVersePointer> GetParallelVersePointer(ModuleVersePointer baseVersePointer, string parallelModuleShortName) { List <ModuleVersePointer> result = null; var parallelBibleInfo = GetParallelBibleInfo(parallelModuleShortName, _configurationManager.ModuleShortName); var parallelBookInfo = parallelBibleInfo[baseVersePointer.BookIndex]; if (parallelBookInfo != null && parallelBookInfo.TryGetValue(baseVersePointer, out ComparisonVersesInfo verseInfo)) { result = verseInfo; } else { result = new List <ModuleVersePointer>(1) { (ModuleVersePointer)baseVersePointer.Clone() } }; return(result); }
private List <ModuleVersePointer> GetParallelVersesList(ModuleVersePointer baseVerse, ComparisonVersesInfo parallelVerses, ref int startIndex, GetAllVersesType getAllVerses, bool isPartParallelVersePointer, List <ModuleVersePointer> prevParallelVerses) { var result = new List <ModuleVersePointer>(); var lastIndex = startIndex; var lastPrevVerse = prevParallelVerses.Count > 0 ? prevParallelVerses.Last() : null; var partIndex = lastPrevVerse != null?lastPrevVerse.PartIndex.GetValueOrDefault(-1) + 1 : 0; bool getAllFirstOtherTypeVerses = startIndex == 0 && parallelVerses.Count > 0 && !baseVerse.IsApocrypha && parallelVerses[0].IsApocrypha; for (int i = startIndex; i < parallelVerses.Count; i++) { if (parallelVerses[i].IsApocrypha == baseVerse.IsApocrypha || getAllVerses == GetAllVersesType.All || getAllFirstOtherTypeVerses) { var parallelVerseToAdd = (ModuleVersePointer)parallelVerses[i].Clone(); if (!parallelVerseToAdd.IsApocrypha) { parallelVerseToAdd.PartIndex = (isPartParallelVersePointer && getAllVerses != GetAllVersesType.One) ? (int?)partIndex++ : parallelVerseToAdd.PartIndex; } else if (parallelVerseToAdd.PartIndex.HasValue) { throw new NotSupportedException(string.Format("Apocrypha part verses are not supported yet. Parallel verse is '{0}'.", parallelVerseToAdd)); } result.Add(parallelVerseToAdd); lastIndex = i + 1; } else { if (getAllVerses != GetAllVersesType.All && result.Count > 0) // то есть IsApocrypha сменилась { break; } if (getAllVerses == GetAllVersesType.AllOfTheSameType && startIndex == 0) // то есть сразу не то пошло { break; } } if (getAllVerses == GetAllVersesType.One && (!getAllFirstOtherTypeVerses || result.Any(v => v.IsApocrypha == baseVerse.IsApocrypha))) { break; } } startIndex = lastIndex; if (result.Count == 0) { ModuleVersePointer parallelVerseToAdd = null; if (!baseVerse.IsApocrypha) { if (lastPrevVerse != null) { if (!lastPrevVerse.PartIndex.HasValue) { lastPrevVerse.PartIndex = partIndex++; } parallelVerseToAdd = (ModuleVersePointer)lastPrevVerse.Clone(); parallelVerseToAdd.PartIndex = isPartParallelVersePointer ? (int?)partIndex++ : null; } else { throw new NotSupportedException(string.Format("Can not find parallel value verse for base verse '{0}'.", baseVerse)); } } else { parallelVerseToAdd = (ModuleVersePointer)baseVerse.Clone(); parallelVerseToAdd.IsEmpty = true; } result.Add(parallelVerseToAdd); } return(result); }