本文整理汇总了C#中TextBuffer.GetText方法的典型用法代码示例。如果您正苦于以下问题:C# TextBuffer.GetText方法的具体用法?C# TextBuffer.GetText怎么用?C# TextBuffer.GetText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TextBuffer
的用法示例。
在下文中一共展示了TextBuffer.GetText方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TextFormattingSource
public TextFormattingSource(
TextBuffer textBuffer
, IClassificationFormatMap classificationFormatMap
, Int32 startIndex
, Int32 length
, IList<ClassificationSpan> classificationSpans
, IList<SpaceNegotiation> spaceNegotiations
)
{
List<SpaceNegotiation> list = null;
if (spaceNegotiations != null)
{
list = new List<SpaceNegotiation>(spaceNegotiations);
list.Sort(new Comparison<SpaceNegotiation>(this.Comparison));
}
String text = textBuffer.GetText(startIndex, length);
_normalizedSpanManager = new NormalizedSpanManager(text, startIndex, classificationSpans, list, classificationFormatMap);
}
示例2: Merge
/*
* Merge
*/
/// <summary>
/// </summary>
/// <exception cref="ArgumentNullException">
/// <para>
/// <paramref name="normalizedChanges"/> is <see langword="null"/>.
/// </para>
/// -or-
/// <para>
/// <paramref name="buffer"/> is <see langword="null"/>.
/// </para>
/// </exception>
/// <exception cref="ArgumentOutOfRangeException">
/// The amount of items in <paramref name="normalizedChanges"/> is less than 1.
/// </exception>
public static TextChange Merge(IList<TextChange> normalizedChanges, TextBuffer buffer)
{
if (normalizedChanges == null)
{
throw new ArgumentNullException("normalizedChanges");
}
if (normalizedChanges.Count < 1)
{
throw new ArgumentOutOfRangeException("normalizedChanges.Count");
}
if (buffer == null)
{
throw new ArgumentNullException("buffer");
}
Int32 position = normalizedChanges[0].Position;
var builder = new StringBuilder();
var builder2 = new StringBuilder();
for (var i = 0; i < normalizedChanges.Count; i++)
{
TextChange change = normalizedChanges[i];
builder.Append(change.OldText);
builder2.Append(change.NewText);
if ((i + 1) < normalizedChanges.Count)
{
Int32 length = normalizedChanges[i + 1].Position - normalizedChanges[i].NewEnd;
String text = buffer.GetText(normalizedChanges[i].NewEnd, length);
builder.Append(text);
builder2.Append(text);
}
}
return new TextChange(position, builder.ToString(), builder2.ToString());
}