本文整理汇总了C#中TextSpan.ToSpan方法的典型用法代码示例。如果您正苦于以下问题:C# TextSpan.ToSpan方法的具体用法?C# TextSpan.ToSpan怎么用?C# TextSpan.ToSpan使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TextSpan
的用法示例。
在下文中一共展示了TextSpan.ToSpan方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetSubjectBufferTextSpanInViewBuffer
// Normally, we could just use a BufferGraph to do the mapping, but our subjectBuffer may be
// disconnected from the view when we are asked to do this mapping.
public ViewTextSpan GetSubjectBufferTextSpanInViewBuffer(TextSpan textSpan)
{
switch (SubjectBufferToTextViewDirection)
{
// The view and subject buffer are the same
case BufferMapDirection.Identity:
return new ViewTextSpan(textSpan);
// The subject buffer contains the view buffer. This happens in debugger intellisense.
case BufferMapDirection.Down:
{
var projection = SubjectBufferSnapshot as IProjectionSnapshot;
var span = MapDownToSnapshot(textSpan.ToSpan(), projection, ViewSnapshot);
return new ViewTextSpan(span.ToTextSpan());
}
// The view buffer contains the subject buffer. This is the typical Razor setup.
case BufferMapDirection.Up:
{
var projection = ViewSnapshot as IProjectionSnapshot;
var span = MapUpToSnapshot(textSpan.ToSpan(), SubjectBufferSnapshot, projection);
return new ViewTextSpan(span.ToTextSpan());
}
default:
Contract.Fail();
return default(ViewTextSpan);
}
}
示例2: ConvertToSpan
public void ConvertToSpan()
{
Action<int, int> del = (start, length) =>
{
var textSpan = new TextSpan(start, length);
var span = textSpan.ToSpan();
Assert.Equal(start, span.Start);
Assert.Equal(length, span.Length);
};
del(0, 5);
del(15, 20);
}
示例3: GetCurrentSpanInSnapshot
internal SnapshotSpan GetCurrentSpanInSnapshot(TextSpan originalSpan, ITextSnapshot textSnapshot)
{
var trackingSpan = this.TextVersion.CreateTrackingSpan(originalSpan.ToSpan(), SpanTrackingMode.EdgeInclusive);
return trackingSpan.GetSpan(textSnapshot);
}
示例4: IntersectsWith
public static bool IntersectsWith(this SnapshotSpan snapshotSpan, TextSpan textSpan)
{
return snapshotSpan.IntersectsWith(textSpan.ToSpan());
}
示例5: Write
public override void Write(TextWriter textWriter, TextSpan span, CancellationToken cancellationToken)
{
this.RoslynSnapshot.Write(textWriter, span.ToSpan());
}
示例6: ToString
public override string ToString(TextSpan span) => TextSnapshot.GetText(span.ToSpan());