本文整理汇总了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;
}
示例2: SnapshotMultipleSpanSourceCodeReader
internal SnapshotMultipleSpanSourceCodeReader(NormalizedSnapshotSpanCollection spans)
{
_spans = spans;
_readers = spans.Select(s => new SnapshotSpanSourceCodeReader(s)).ToArray();
_index = 0;
}
示例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);
}
示例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();
}
}