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


C# ITextBuffer.CreateSnapshot方法代码示例

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


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

示例1: ReadOnlyDocument

		public ReadOnlyDocument(ITextBuffer textBuffer)
		{
			// ensure that underlying buffer is immutable
			this.textBuffer = textBuffer.CreateSnapshot();
			List<int> lines = new List<int>();
			lines.Add(0);
			int offset = 0;
			string newlineType;
			var textSource = DocumentUtilitites.GetTextSource(this.textBuffer);
			while ((offset = ICSharpCode.AvalonEdit.Document.TextUtilities.FindNextNewLine(textSource, offset, out newlineType)) >= 0) {
				offset += newlineType.Length;
				lines.Add(offset);
			}
			this.lines = lines.ToArray();
		}
开发者ID:Bombadil77,项目名称:SharpDevelop,代码行数:15,代码来源:ReadOnlyDocument.cs

示例2: BeginParse

		/// <summary>
		/// Begins an asynchronous reparse.
		/// This method is thread-safe.
		/// </summary>
		/// <returns>
		/// Returns a task that will make the parse result available.
		/// </returns>
		/// <remarks>
		/// EnqueueForParsing has been renamed to BeginParse and now provides a future (Task&lt;ParseInformation&gt;)
		/// to allow waiting for the result. However, to avoid deadlocks, this should not be done by any
		/// thread the parser might be waiting for  (especially the main thread).
		/// 
		/// Unlike BeginParse().Wait(), ParseFile() is safe to call from the main thread.
		/// </remarks>
		public static Task<ParseInformation> BeginParse(string fileName, ITextBuffer fileContent)
		{
			if (fileContent == null)
				throw new ArgumentNullException("fileContent");
			// create snapshot (in case someone passes a mutable document to BeginParse)
			return GetFileEntry(fileName, true).BeginParse(fileContent.CreateSnapshot());
		}
开发者ID:Bombadil77,项目名称:SharpDevelop,代码行数:21,代码来源:ParserService.cs


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