当前位置: 首页>>代码示例>>C#>>正文


C# SnapshotPoint.CompareTo方法代码示例

本文整理汇总了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;
                }
            }
开发者ID:nileshjagtap,项目名称:roslyn,代码行数:47,代码来源:InteractiveWindow.UIThreadOnly.cs


注:本文中的SnapshotPoint.CompareTo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。