当前位置: 首页>>代码示例>>C#>>正文


C# IScripture.FindBook方法代码示例

本文整理汇总了C#中IScripture.FindBook方法的典型用法代码示例。如果您正苦于以下问题:C# IScripture.FindBook方法的具体用法?C# IScripture.FindBook怎么用?C# IScripture.FindBook使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IScripture的用法示例。


在下文中一共展示了IScripture.FindBook方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AttachAnnotatedObjects

		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Attaches the annotated objects to the specifed annotation.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		private static void AttachAnnotatedObjects(IScripture scr, int bookNum,
			IScrScriptureNote scrNote)
		{
			int iSection, iPara, ichStart, ichEnd;
			ScrReference scrRef = new ScrReference(scrNote.BeginRef, scr.Versification);
			if (TeEditingHelper.FindTextInVerse(scr, scrNote.CitedTextTss,
				 scrRef, true, out iSection, out iPara, out ichStart, out ichEnd))
			{
				IScrBook book = scr.FindBook(bookNum);
				Debug.Assert(book != null);
				scrNote.BeginOffset = ichStart;
				scrNote.EndOffset = ichEnd;

				if (iSection == -1)
					scrNote.BeginObjectRA = scrNote.EndObjectRA = book.TitleOA.ParagraphsOS[iPara];
				else
				{
					scrNote.BeginObjectRA = scrNote.EndObjectRA =
						book.SectionsOS[iSection].ContentOA.ParagraphsOS[iPara];
				}
			}
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:27,代码来源:XmlScrNote.cs

示例2: GetVerseText

		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Find a verse and return the text of the verse in one or more
		/// <see cref="VerseTextSubstring"/> objects.
		/// </summary>
		/// <param name="scr">The scripture.</param>
		/// <param name="targetRef">The verse reference to look for</param>
		/// <returns>
		/// The <see cref="VerseTextSubstring"/> objects, each representing
		/// one paragraph worth of verse text (e.g., to deal with poetry)
		/// </returns>
		/// <remarks>Verses would not normally be split across sections, but there are a few
		/// places, such as the end of I Cor. 12, where it can happen.
		/// ENHANCE: Logicially, this method probably really belongs on Scripture, but currently
		/// that FDO doesn't reference ScrUtils (which is where ScrReference is). It probably
		/// could reference it, if we wanted it to. Another option would be to create an
		/// extension method for it, but I'm not sure where it would go.
		/// </remarks>
		/// ------------------------------------------------------------------------------------
		public static IEnumerable<VerseTextSubstring> GetVerseText(IScripture scr, ScrReference targetRef)
		{
			if (scr.Versification != targetRef.Versification)
				targetRef = new ScrReference(targetRef, scr.Versification);

			List<VerseTextSubstring> verseText = new List<VerseTextSubstring>();

			// Find the book that the reference is in
			IScrBook book = scr.FindBook(targetRef.Book);
			if (book == null)
				return verseText;

			if (targetRef.IsBookTitle)
			{
				foreach (IStTxtPara para in book.TitleOA.ParagraphsOS)
				{
					verseText.Add(new VerseTextSubstring(para.Contents, -1,
						para.IndexInOwner, 0, ScrBookTags.kflidTitle));
				}
				return verseText;
			}

			int iSection = 0;
			// Look through the sections for the target reference
			foreach (IScrSection section in book.SectionsOS)
			{
				if (!section.ContainsReference(targetRef))
				{
					if (verseText.Count > 0)
						return verseText;
				}
				else
				{
					int iPara = 0;
					// Look through each paragraph in the section
					foreach (IScrTxtPara para in section.ContentOA.ParagraphsOS)
					{
						// Search for target reference in the verses in the paragraph
						using (ScrVerseSet verseSet = new ScrVerseSet(para))
						{
							foreach (ScrVerse verse in verseSet)
							{
								if (verse.StartRef <= targetRef && targetRef <= verse.EndRef)
								{
									// If the paragraph has a chapter number, the verse iterator
									// returns this as a separate string with the same reference
									// as the following verse.
									// We want to return the verse string, not the chapter number
									// run, so we skip a string that has only numeric characters.
									ITsString verseTextInPara = verse.Text;
									if (verse.Text.RunCount > 0 &&
										verse.Text.Style(0) == ScrStyleNames.VerseNumber)
									{
										verseTextInPara = verseTextInPara.Substring(verse.Text.get_LimOfRun(0));
									}

									if (!IsNumber(verseTextInPara.Text)) // skip chapter number strings
									{
										int ichStart = (verseText.Count == 0) ? verse.TextStartIndex : 0;
										verseText.Add(new VerseTextSubstring(verseTextInPara, iSection,
											iPara, ichStart, ScrSectionTags.kflidContent));
										break;
									}
								}
								else if (verseText.Count > 0)
									return verseText;
							}
						}
						iPara++;
					}
				}
				iSection++;
			}

			return verseText;
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:95,代码来源:TeEditingHelper.cs


注:本文中的IScripture.FindBook方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。