エディターのインポート

コア エディターへのさまざまな種類のアクセスを使用して、拡張機能を提供する多数のエディター サービス、ファクトリ、およびブローカーをインポートできます。 たとえば、ITextStructureNavigatorSelectorService をインポートして、特定のコンテンツ タイプの ITextStructureNavigator を提供できます (このナビゲーターを使用すると、テキスト バッファーに対してさまざまな種類の検索を実行できます)。

エディターのインポートを使用するには、Managed Extensibility Framework コンポーネント パーツをエクスポートするクラスのフィールドまたはプロパティとしてインポートします。

Note

Managed Extensibility Framework の詳細については、「Managed Extensibility Framework (MEF)」を参照してください。

インポート構文

次の例は、エディター オプションのファクトリ サービスをインポートする方法を示しています。

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

サービスをプロパティではなくフィールドとしてインポートする場合は、変数に割り当てられていないことに関するコンパイラの警告が表示されないように、宣言で null に設定する必要があります。

[Import]
internal IEditorOptionsFactoryService m_editorOptions = null;

インポートを使用するその他の例については、次のチュートリアルを参照してください。

サービス プロバイダーをインポートする

同じ方法で (アセンブリ Microsoft.VisualStudio.Shell.Immutable.10.0 内にある) SVsServiceProvider をインポートして、Visual Studio サービスへのアクセスを取得することもできます。

[Import]
internal SVsServiceProvider ServiceProvider = null;

詳細については、「チュートリアル: エディター拡張機能から DTE オブジェクトにアクセスする」を参照してください。

サービス

通常、エディター サービスはサービスを提供する 1 つのエンティティであり、複数のコンポーネント間で共有されます。

インポート 提供内容
IFileExtensionRegistryService ファイル拡張子と IContentType オブジェクトの間のリレーションシップ。
IContentTypeRegistryService IContentType オブジェクトのコレクション。
IVsFontsAndColorsInformationService IVsFontsAndColorsInformation オブジェクト。
IVsEditorAdaptersFactoryService 多くのエディター アダプター オブジェクト:

IVsCodeWindow

IVsTextBuffer

IVsTextBufferCoordinator

IVsTextView
IIncrementalSearchFactoryService 指定されたテキスト ビューの IIncrementalSearch オブジェクト。
ITextBufferFactoryService ITextBuffer。
ITextDocumentFactoryService ITextDocument。
IDifferenceService 相違点の IDifferenceCollection<T>。
IHierarchicalStringDifferenceService 相違点の IHierarchicalDifferenceCollection。
IProjectionBufferFactoryService IProjectionBuffer または IElisionBuffer。
IBufferGraphFactoryService 一連の ITextBuffer オブジェクトの IBufferGraph。
IClassifierAggregatorService ITextBuffer の IClassifier。
IViewClassifierAggregatorService ITextView の IClassifier。
IClassificationFormatMapService ITextView の IClassificationFormatMap。
IEditorFormatMapService ITextView の IEditorFormatMap。
IClassificationTypeRegistryService IClassificationType オブジェクトのコレクションを保持します。
IBufferTagAggregatorFactoryService テキスト バッファーの ITagAggregator<T>。
IViewTagAggregatorFactoryService テキスト ビューの ITagAggregator<T>。
IEditorOptionsFactoryService 指定したスコープの IEditorOptions。
IScrollMapFactoryService テキスト ビューの IScrollMap。
ISmartIndentationService ITextView の ISmartIndent。
ISmartIndentationService ISmartIndentProvider オブジェクトを使用して自動インデントを取得します。
ITextEditorFactoryService IWpfTextView の IWpfTextViewHost を管理します。
IFormattedTextSourceFactoryService IFormattedLineSource。
IRtfBuilderService 一連のスナップショット スパンから RTF 形式のテキストを生成します。
ITextAndAdornmentSequencerFactoryService ITextView の ITextAndAdornmentSequencer。
ITextParagraphPropertiesFactoryService ビュー内のテキスト行を書式設定するための TextParagraphProperties。
IEditorOperationsFactoryService ITextView の IEditorOperations オブジェクト。
ITextSearchService テキスト スナップショットを検索します。
ITextStructureNavigatorSelectorService IContentType による ITextBuffer の ITextStructureNavigator。
IOutliningManagerService テキスト ビューの IOutliningManager。
IGlyphService グリフの標準セット。
IIntellisenseSessionStackMapService ITextView の IIntellisenseSessionStack。
IWpfKeyboardTrackingService キーボード処理を追跡します。
IStandardClassificationService 標準 IClassificationType オブジェクト。
ITextUndoHistoryRegistry テキスト バッファーと ITextUndoHistory オブジェクトの間のリレーションシップを維持します。

その他のインポート

プロバイダー ファクトリとブローカーは、通常、複数のコンポーネントに複数のインスタンスを持つことができるエンティティです。

インポート 提供内容
IErrorProviderFactory 指定されたバッファーの型 ErrorTag) の SimpleTagger<T>。
ITextMarkerProviderFactory テキスト マーカー タガー (型 TextMarkerTag の SimpleTagger<T>)。
IToolTipProviderFactory 指定された ITextView の IToolTipProvider。
ICompletionBroker ICompletionSession。
IQuickInfoBroker IQuickInfoSession。
ISignatureHelpBroker ISignatureHelpSession。

関連項目