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


C# NormalizedSnapshotSpanCollection.First方法代码示例

本文整理汇总了C#中NormalizedSnapshotSpanCollection.First方法的典型用法代码示例。如果您正苦于以下问题:C# NormalizedSnapshotSpanCollection.First方法的具体用法?C# NormalizedSnapshotSpanCollection.First怎么用?C# NormalizedSnapshotSpanCollection.First使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在NormalizedSnapshotSpanCollection的用法示例。


在下文中一共展示了NormalizedSnapshotSpanCollection.First方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateElisionBufferWithoutIndentation

        public static IElisionBuffer CreateElisionBufferWithoutIndentation(
            this IProjectionBufferFactoryService factoryService,
            IEditorOptions editorOptions,
            IContentType contentType,
            IEnumerable<SnapshotSpan> exposedSpans)
        {
            var spans = new NormalizedSnapshotSpanCollection(exposedSpans);

            if (spans.Count > 0)
            {
                // BUG(6335): We have to make sure that the spans refer to the current snapshot of
                // the buffer.
                var buffer = spans.First().Snapshot.TextBuffer;
                var currentSnapshot = buffer.CurrentSnapshot;
                spans = new NormalizedSnapshotSpanCollection(
                    spans.Select(s => s.TranslateTo(currentSnapshot, SpanTrackingMode.EdgeExclusive)));
            }

            contentType = contentType ?? factoryService.ProjectionContentType;
            var elisionBuffer = factoryService.CreateElisionBuffer(
                null, spans, ElisionBufferOptions.None, contentType);

            if (spans.Count > 0)
            {
                var snapshot = spans.First().Snapshot;
                var buffer = snapshot.TextBuffer;

                // We need to figure out the shorted indentation level of the exposed lines.  We'll
                // then remove that indentation from all lines.
                var indentationColumn = DetermineIndentationColumn(editorOptions, spans);

                var spansToElide = new List<Span>();

                foreach (var span in spans)
                {
                    var startLineNumber = snapshot.GetLineNumberFromPosition(span.Start);
                    var endLineNumber = snapshot.GetLineNumberFromPosition(span.End);

                    for (var lineNumber = startLineNumber; lineNumber <= endLineNumber; lineNumber++)
                    {
                        var line = snapshot.GetLineFromLineNumber(lineNumber);
                        var lineOffsetOfColumn = line.GetLineOffsetFromColumn(indentationColumn, editorOptions);
                        spansToElide.Add(Span.FromBounds(line.Start, line.Start + lineOffsetOfColumn));
                    }
                }

                elisionBuffer.ElideSpans(new NormalizedSpanCollection(spansToElide));
            }

            return elisionBuffer;
        }
开发者ID:XieShuquan,项目名称:roslyn,代码行数:51,代码来源:IProjectionBufferFactoryServiceExtensions.cs

示例2: CoalesceSpans

        internal static NormalizedSnapshotSpanCollection CoalesceSpans(NormalizedSnapshotSpanCollection normalizedSpans)
        {
            var snapshot = normalizedSpans.First().Snapshot;

            // Coalesce the spans if there are a lot of them.
            if (normalizedSpans.Count > CoalesceDifferenceCount)
            {
                // Spans are normalized.  So to find the whole span we just go from the
                // start of the first span to the end of the last span.
                normalizedSpans = new NormalizedSnapshotSpanCollection(snapshot.GetSpanFromBounds(
                    normalizedSpans.First().Start,
                    normalizedSpans.Last().End));
            }

            return normalizedSpans;
        }
开发者ID:GloryChou,项目名称:roslyn,代码行数:16,代码来源:BatchChangeNotifier.cs


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