本文整理汇总了C#中SnapshotPoint.CompareTo方法的典型用法代码示例。如果您正苦于以下问题:C# SnapshotPoint.CompareTo方法的具体用法?C# SnapshotPoint.CompareTo怎么用?C# SnapshotPoint.CompareTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SnapshotPoint
的用法示例。
在下文中一共展示了SnapshotPoint.CompareTo方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CompareToSpan
/// <summary>
/// Returns negative value if the point is less than the span start,
/// positive if greater than or equal to the span end, and 0 otherwise.
/// </summary>
private static int CompareToSpan(ITextView textView, ReadOnlyCollection<SnapshotSpan> sourceSpans, int index, SnapshotPoint point)
{
// If this span is zero-width and there are multiple projections of the
// containing snapshot in the projection buffer, MapUpToBuffer will return
// multiple (ambiguous) projection spans. To avoid that, we compare the
// point to the end point of the nearest non-zero width span instead.
int indexToCompare = index;
while (sourceSpans[indexToCompare].IsEmpty)
{
if (indexToCompare == 0)
{
// Empty span at start of buffer. Point
// must be to the right of span.
return 1;
}
indexToCompare--;
}
var sourceSpan = sourceSpans[indexToCompare];
Debug.Assert(sourceSpan.Length > 0);
var mappedSpans = textView.BufferGraph.MapUpToBuffer(sourceSpan, SpanTrackingMode.EdgeInclusive, textView.TextBuffer);
Debug.Assert(mappedSpans.Count == 1);
var mappedSpan = mappedSpans[0];
Debug.Assert(mappedSpan.Length == sourceSpan.Length);
if (indexToCompare < index)
{
var result = point.CompareTo(mappedSpan.End);
return (result == 0) ? 1 : result;
}
else
{
var result = point.CompareTo(mappedSpan.Start);
if (result <= 0)
{
return result;
}
result = point.CompareTo(mappedSpan.End);
return (result < 0) ? 0 : 1;
}
}