本文整理汇总了C#中TextChange.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# TextChange.ToString方法的具体用法?C# TextChange.ToString怎么用?C# TextChange.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TextChange
的用法示例。
在下文中一共展示了TextChange.ToString方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CheckForStructureChanges
/// <summary>
/// Determines if a change will cause a structural change to the document and if not, applies it to the
/// existing tree. If a structural change would occur, automatically starts a reparse.
/// </summary>
/// <remarks>
/// NOTE: The initial incremental parsing check and actual incremental parsing (if possible) occurs
/// on the caller's thread. However, if a full reparse is needed, this occurs on a background thread.
/// </remarks>
/// <param name="change">The change to apply to the parse tree.</param>
/// <returns>A <see cref="PartialParseResult"/> value indicating the result of the incremental parse.</returns>
public virtual PartialParseResult CheckForStructureChanges(TextChange change)
{
// Validate the change
long? elapsedMs = null;
#if EDITOR_TRACING
var sw = new Stopwatch();
sw.Start();
#endif
RazorEditorTrace.TraceLine(RazorResources.FormatTrace_EditorReceivedChange(Path.GetFileName(FileName), change));
if (change.NewBuffer == null)
{
throw new ArgumentException(
RazorResources.FormatStructure_Member_CannotBeNull(nameof(change.NewBuffer), nameof(TextChange)),
nameof(change));
}
var result = PartialParseResult.Rejected;
// If there isn't already a parse underway, try partial-parsing
var changeString = string.Empty;
using (_parser.SynchronizeMainThreadState())
{
// Capture the string value of the change while we're synchronized
changeString = change.ToString();
// Check if we can partial-parse
if (CurrentParseTree != null && _parser.IsIdle)
{
result = TryPartialParse(change);
}
}
// If partial parsing failed or there were outstanding parser tasks, start a full reparse
if ((result & PartialParseResult.Rejected) == PartialParseResult.Rejected)
{
_parser.QueueChange(change);
}
// Otherwise, remember if this was provisionally accepted for next partial parse
LastResultProvisional = (result & PartialParseResult.Provisional) == PartialParseResult.Provisional;
VerifyFlagsAreValid(result);
#if EDITOR_TRACING
sw.Stop();
elapsedMs = sw.ElapsedMilliseconds;
sw.Reset();
#endif
RazorEditorTrace.TraceLine(RazorResources.FormatTrace_EditorProcessedChange(
Path.GetFileName(FileName),
changeString,
elapsedMs.HasValue ? elapsedMs.Value.ToString(CultureInfo.InvariantCulture) : "?",
result.ToString()));
return result;
}