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


C# NormalizedSnapshotSpanCollection.Select方法代码示例

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


在下文中一共展示了NormalizedSnapshotSpanCollection.Select方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: SnapshotMultipleSpanSourceCodeReader

 internal SnapshotMultipleSpanSourceCodeReader(NormalizedSnapshotSpanCollection spans)
 {
     _spans = spans;
     _readers = spans.Select(s => new SnapshotSpanSourceCodeReader(s)).ToArray();
     _index = 0;
 }
开发者ID:TerabyteX,项目名称:main,代码行数:6,代码来源:SnapshotMultpleSpanSourceCodeReader.cs

示例3: AddSpans

 public void AddSpans(NormalizedSnapshotSpanCollection snapshotSpanCollection)
 {
     // TODO: custom tracking spans!
     var newTrackingSpans = snapshotSpanCollection.Select(ss => ss.Snapshot.CreateTrackingSpan(ss, SpanTrackingMode.EdgeInclusive, TrackingFidelityMode.Forward));
     AddSpans(newTrackingSpans);
 }
开发者ID:GloryChou,项目名称:roslyn,代码行数:6,代码来源:LinkedEditsTracker.cs

示例4: GetText

            /// <summary>
            /// Get the text of the given spans.
            /// If there are multiple spans, then return the concatenation of the text of each span plus a newline character,
            /// otherwise, simply return the text of the only span.
            /// </summary>
            private string GetText(NormalizedSnapshotSpanCollection spans)
            {
                Debug.Assert(spans.Count > 0);

                if (spans.Count > 1)
                {
                    var builder = new StringBuilder();
                    builder.Append(string.Join(EditorOperations.Options.GetNewLineCharacter(), spans.Select((span) => span.GetText()).ToArray()));

                    // Append one last newline character
                    builder.Append(EditorOperations.Options.GetNewLineCharacter());
                    return builder.ToString();
                }
                else
                {
                    return spans[0].GetText();
                }
            }
开发者ID:jeffanders,项目名称:roslyn,代码行数:23,代码来源:InteractiveWindow.UIThreadOnly.cs


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