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


C# TextSpan.GetText方法代码示例

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


在下文中一共展示了TextSpan.GetText方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetEditorActions

        /// <summary>
        /// Gets the editor actions associated with the given TextSpan.
        /// </summary>
        /// <param name="block">The block.</param>
        /// <param name="textSpan">The text span.</param>
        /// <returns>
        /// A list of editor actions associated with this span.
        /// </returns>
        /// <remarks>
        /// This will be called within a read-only lock.
        /// </remarks>
        public IList<IEditorAction> GetEditorActions(
			Block block,
			TextSpan textSpan)
        {
            // We only get to this point if we have a misspelled word.
            string word = textSpan.GetText(block.Text);

            // Get the suggestions for the word.
            IList<SpellingSuggestion> suggestions = GetSuggestions(word);

            // Go through the suggestions and create an editor action for each one.
            // These will already be ordered coming out of the GetSuggestions()
            // method.
            BlockCommandSupervisor commands = block.Project.Commands;
            var actions = new List<IEditorAction>(suggestions.Count);

            foreach (SpellingSuggestion suggestion in suggestions)
            {
                // Figure out the operation we'll be using to implement the change.
                var command =
                    new ReplaceTextCommand(
                        new BlockPosition(block.BlockKey, textSpan.StartTextIndex),
                        textSpan.Length,
                        suggestion.Suggestion);

                // Create the suggestion action, along with the replacement command.
                var action =
                    new EditorAction(
                        string.Format("Change to \"{0}\"", suggestion.Suggestion),
                        new HierarchicalPath("/Plugins/Spelling/Change"),
                        context => commands.Do(command, context));

                actions.Add(action);
            }

            // Add the additional editor actions from the plugins.
            foreach (ISpellingProjectPlugin controller in SpellingControllers)
            {
                IEnumerable<IEditorAction> additionalActions =
                    controller.GetAdditionalEditorActions(word);
                actions.AddRange(additionalActions);
            }

            // Return all the change actions.
            return actions;
        }
开发者ID:dmoonfire,项目名称:author-intrusion-cil,代码行数:57,代码来源:SpellingFrameworkProjectPlugin.cs


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