本文整理汇总了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();
}
示例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<ParseInformation>)
/// 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());
}