编辑导入

您可以导入提供该扩展以不同的类型设置为核心编辑器的访问的编辑服务、工厂和代理。 例如,可以导入 ITextStructureNavigatorSelectorService 提供了 ITextStructureNavigator 为特定内容类型。 (此浏览器允许您执行不同的类型在文本缓冲区的搜索。)

若要使用编辑导入,从中导入它作为导出 managed extensibility framework 由分部类的字段或属性。

备注

有关 managed extensibility framework 的更多信息,请参见 Managed Extensibility Framework (MEF)

导入语法

下面的示例演示如何导入编辑器选项工厂服务。

[Import]
internal IEditorOptionsFactoryService EditorOptions { get; set; }

如果要导入服务用作字段而不是属性,则应将其设置为在声明中 null 以避免有关不分配的编译器警告给变量:

[Import]
internal IEditorOptionsFactoryService m_editorOptions = null;

有关更多示例导入,请参见以下演练:

演练:创建标志符号边距

演练:自定义文本视图

演练:显示文本

演练:显示以前的工具提示

演练:显示签名帮助

演练:显示的语句完成

演练:显示 SmartTags

导入服务提供程序

然后可以象也将导入到 Visual Studio 服务的一 SVsServiceProvider (找到程序集中 Microsoft.VisualStudio.Shell.Immutable.10.0) 获取访问:

[Import]
internal SVsServiceProvider ServiceProvider = null; 

有关更多信息,请参见演练:访问 DTE 对象从编辑器扩展

服务

编辑服务通常是一个服务的单个实体和在多个元素之间共享。

导入

提供

IFileExtensionRegistryService

文件扩展名和 IContentType 对象之间的关系。

IContentTypeRegistryService

IContentType 对象的集合。

IVsFontsAndColorsInformationService

IVsFontsAndColorsInformation 对象

IVsEditorAdaptersFactoryService

许多编辑器适配器对象:

IVsCodeWindow

IVsTextBuffer

IVsTextBufferCoordinator

IVsTextView

IIncrementalSearchFactoryService

给定文本视图的一 IIncrementalSearch 对象。

ITextBufferFactoryService

一个 ITextBuffer

ITextDocumentFactoryService

一个 ITextDocument

IDifferenceService

差异的 IDifferenceCollection

IHierarchicalStringDifferenceService

差异 IHierarchicalDifferenceCollection

IProjectionBufferFactoryService

IProjectionBufferIElisionBuffer

IBufferGraphFactoryService

IBufferGraph 设置 ITextBuffer 对象。

IClassifierAggregatorService

ITextBufferIClassifier

IViewClassifierAggregatorService

ITextViewIClassifier

IClassificationFormatMapService

ITextViewIClassificationFormatMap

IEditorFormatMapService

ITextViewIEditorFormatMap

IClassificationTypeRegistryService

维护 IClassificationType 对象的集合。

IBufferTagAggregatorFactoryService

文本缓冲区的 ITagAggregator

IViewTagAggregatorFactoryService

文本视图的 ITagAggregator

IEditorOptionsFactoryService

指定范围的 IEditorOptions

IScrollMapFactoryService

文本视图的 IScrollMap

ISmartIndentationService

ITextViewISmartIndent

ISmartIndentationService

通过 ISmartIndentProvider 对象获取自动缩进。

ITextEditorFactoryService

管理 IWpfTextViewIWpfTextViewHost

IFormattedTextSourceFactoryService

一个 IFormattedLineSource

IRtfBuilderService

生成 RTF 格式已从集的文本快照范围。

ITextAndAdornmentSequencerFactoryService

ITextViewITextAndAdornmentSequencer

ITextParagraphPropertiesFactoryService

格式化文本行的 TextParagraphProperties 在视图。

IEditorOperationsFactoryService

ITextView的一 IEditorOperations 对象。

ITextSearchService

搜索一个文本快照。

ITextStructureNavigatorSelectorService

ITextBufferITextStructureNavigatorIContentType

IOutliningManagerService

文本视图的 IOutliningManager

IGlyphService

标准标志符号集。

IIntellisenseSessionStackMapService

ITextViewIIntellisenseSessionStack

IWpfKeyboardTrackingService

跟踪键盘处理。

IStandardClassificationService

标准 IClassificationType 对象。

ITextUndoHistoryRegistry

维护文本缓冲区和 ITextUndoHistory 对象之间的关系。

其他导入

提供程序工厂和代理是可以在多个组件的多个实例的常规实体。

导入

提供

IErrorProviderFactory

SimpleTagger 给定缓冲区的类型 ErrorTag)。

ITextMarkerProviderFactory

文本标记 ( SimpleTagger 类型 TextMarkerTag)。

IToolTipProviderFactory

特定 ITextViewIToolTipProvider

ICompletionBroker

一个 ICompletionSession

IQuickInfoBroker

一个 IQuickInfoSession

ISignatureHelpBroker

一个 ISignatureHelpSession

请参见

概念

编辑扩展点