本文整理汇总了C#中System.Web.Razor.Text.TextChange.ApplyChange方法的典型用法代码示例。如果您正苦于以下问题:C# TextChange.ApplyChange方法的具体用法?C# TextChange.ApplyChange怎么用?C# TextChange.ApplyChange使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Web.Razor.Text.TextChange
的用法示例。
在下文中一共展示了TextChange.ApplyChange方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UpdateSpan
protected virtual SpanBuilder UpdateSpan(Span target, TextChange normalizedChange)
{
string newContent = normalizedChange.ApplyChange(target);
SpanBuilder newSpan = new SpanBuilder(target);
newSpan.ClearSymbols();
foreach (ISymbol sym in Tokenizer(newContent))
{
sym.OffsetStart(target.Start);
newSpan.Accept(sym);
}
if (target.Next != null)
{
SourceLocation newEnd = SourceLocationTracker.CalculateNewLocation(target.Start, newContent);
target.Next.ChangeStart(newEnd);
}
return newSpan;
}
示例2: TryAcceptChange
private PartialParseResult TryAcceptChange(Span target, TextChange change, PartialParseResult acceptResult = PartialParseResult.Accepted)
{
string content = change.ApplyChange(target);
if (StartsWithKeyword(content))
{
return PartialParseResult.Rejected | PartialParseResult.SpanContextChanged;
}
return acceptResult;
}
示例3: ApplyChangeWithReplacedTextReturnsNewContentWithChangeApplied
public void ApplyChangeWithReplacedTextReturnsNewContentWithChangeApplied()
{
// Arrange
var newBuffer = new StringTextBuffer("abcdefg");
var oldBuffer = new StringTextBuffer("");
var textChange = new TextChange(1, 1, oldBuffer, 2, newBuffer);
// Act
string text = textChange.ApplyChange("abcdefg", 1);
// Assert
Assert.Equal("bcbcdefg", text);
}
示例4: ApplyChangeWithInsertedTextReturnsNewContentWithChangeApplied
public void ApplyChangeWithInsertedTextReturnsNewContentWithChangeApplied()
{
// Arrange
var newBuffer = new StringTextBuffer("test");
var oldBuffer = new StringTextBuffer("");
var textChange = new TextChange(0, 0, oldBuffer, 3, newBuffer);
// Act
string text = textChange.ApplyChange("abcd", 0);
// Assert
Assert.Equal("tesabcd", text);
}
示例5: UpdateContent
private void UpdateContent(TextChange change) {
// Update the span's content
Content = change.ApplyChange(this);
ClearCachedStartPoints(Next);
}