本文整理汇总了C#中TextRange.GetText方法的典型用法代码示例。如果您正苦于以下问题:C# TextRange.GetText方法的具体用法?C# TextRange.GetText怎么用?C# TextRange.GetText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TextRange
的用法示例。
在下文中一共展示了TextRange.GetText方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateNumberConstant
/// <summary>
/// Creates the number constant.
/// </summary>
public JsonNode CreateNumberConstant(TextRange textRange)
{
Assume.NotNull(textRange, nameof(textRange));
var text = textRange.GetText();
Decimal value;
if (!Decimal.TryParse(text, NumberStyles.Any, CultureInfo.InvariantCulture, out value))
throw new NotSupportedException(String.Format("Not supported number format: {0}", text));
return new NumberConstant(value, textRange);
}
示例2: CreateBooleanConstant
/// <summary>
/// Creates the boolean constant.
/// </summary>
public JsonNode CreateBooleanConstant(TextRange textRange)
{
Assume.NotNull(textRange, nameof(textRange));
var text = textRange.GetText();
Boolean value;
if (text == "false") value = false;
else if (text == "true") value = true;
else throw new NotSupportedException(String.Format("Invalid text of boolean constant: {0}.", text));
return new BooleanConstant(value, textRange);
}
示例3: SelectElement
/// <summary>
/// Selects the element.
/// </summary>
public override IEnumerable<TextRange> SelectElement(TextRange textRange)
{
var textDocument = textRange.TextDocument;
var text = textRange.GetText();
var index = 0;
var match = _regex.Match(text, index);
while (match != Match.Empty)
{
yield return textDocument.CreateOrGetTextRange(textRange.Start + index, textRange.Start + match.Index);
index = match.Index + match.Length;
match = _regex.Match(text, index);
}
yield return textDocument.CreateOrGetTextRange(textRange.Start + index, textRange.Stop);
}
示例4: SelectElement
/// <summary>
/// Filters the specified element. Returns true if specified element is in the selection otherwise false.
/// </summary>
public override IEnumerable<TextRange> SelectElement(TextRange textRange)
{
var textDocument = textRange.TextDocument;
var text = textRange.GetText();
for (var i = 0; i < text.Length; i++)
{
var start = textRange.Start + i;
var character = text[i];
var isLowerCaseAllowed = (IsLowerCase && Char.IsLower(character));
var isUpperCaseAllowed = (IsUpperCase && Char.IsUpper(character));
var isPunctuationAllowed = (IsPunctuation && Char.IsPunctuation(character));
var isDigitAllowed = (IsDigit && Char.IsDigit(character));
if (!IsAttributeSpecified || isLowerCaseAllowed || isUpperCaseAllowed ||
isDigitAllowed || isPunctuationAllowed)
yield return textDocument.CreateOrGetTextRange(start, start + 1);
}
}
示例5: CreateStringConstant
/// <summary>
/// Creates the string constant.
/// </summary>
public JsonNode CreateStringConstant(TextRange textRange)
{
Assume.NotNull(textRange, nameof(textRange));
var value = textRange.GetText();
return new StringConstant(value, textRange);
}
示例6: SelectElement
/// <summary>
/// Selects the element.
/// </summary>
public override IEnumerable<TextRange> SelectElement(TextRange textRange)
{
var textDocument = textRange.TextDocument;
var text = textRange.GetText();
var index = 0;
var firstWhitespacePosition = 0;
do
{
firstWhitespacePosition = text.IndexOfAny(separators, index);
if (firstWhitespacePosition == -1) break;
var result = text.Substring(index, firstWhitespacePosition - index);
if (isWord(result))
yield return textDocument.CreateOrGetTextRange(textRange.Start + index, textRange.Start + firstWhitespacePosition);
index = firstWhitespacePosition + 1;
} while (firstWhitespacePosition != -1);
var startLastWord = textRange.Start + index;
var stopLastWord = textRange.Start + text.Length;
var lastWord = text.Substring(index, text.Length - index);
if (Math.Abs(stopLastWord - startLastWord) != 0 && isWord(lastWord))
yield return textDocument.CreateOrGetTextRange(startLastWord, stopLastWord);
}