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


C# TextRange.GetText方法代码示例

本文整理汇总了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);
        }
开发者ID:szabototo89,项目名称:CodeSharper,代码行数:14,代码来源:IJsonSyntaxTreeFactory.cs

示例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);
        }
开发者ID:szabototo89,项目名称:CodeSharper,代码行数:14,代码来源:IJsonSyntaxTreeFactory.cs

示例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);
        }
开发者ID:szabototo89,项目名称:CodeSharper,代码行数:19,代码来源:TextSeparatorSelector.cs

示例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);
            }
        }
开发者ID:szabototo89,项目名称:CodeSharper,代码行数:24,代码来源:CharacterSelector.cs

示例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);
 }
开发者ID:szabototo89,项目名称:CodeSharper,代码行数:9,代码来源:IJsonSyntaxTreeFactory.cs

示例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);
        }
开发者ID:szabototo89,项目名称:CodeSharper,代码行数:27,代码来源:WordSelector.cs


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