Partilhar via


IFeatureServiceFactory Interface

Definition

Service that provides IFeatureServices used to track feature availability and to request feature to be disabled. Feature may be tracked by scope, using GetOrCreate(IPropertyOwner) and passing IPropertyOwner e.g. a text view. or throughout the application using GlobalFeatureService.

Features are implemented by exporting FeatureDefinition and grouped using BaseDefinitionAttribute. Grouping allows alike features to be disabling at once. Grouping also relieves IFeatureController from updating its code when new feature of appropriate category is introduced. Standard editor feature names are available in PredefinedEditorFeatureNames.

public interface class IFeatureServiceFactory
public interface IFeatureServiceFactory
type IFeatureServiceFactory = interface
Public Interface IFeatureServiceFactory

Examples

In an exported MEF part:

[Import]
IFeatureServiceFactory FeatureServiceFactory;

IFeatureService globalService = FeatureServiceFactory.GlobalFeatureService;
IFeatureService localService = FeatureServiceFactory.GetOrCreate(scope); // scope is an IPropertyOwner

// Also have a reference to <xref data-throw-if-not-resolved="true" uid="Microsoft.VisualStudio.Utilities.IFeatureController"></xref>:
IFeatureController MyFeatureController;
// Interact with the <xref data-throw-if-not-resolved="true" uid="Microsoft.VisualStudio.Utilities.IFeatureService"></xref>:
globalService.Disable(PredefinedEditorFeatureNames.Popup, MyFeatureController);
localService.IsEnabled(PredefinedEditorFeatureNames.Completion); // returns false, because Popup is a base definition of Completion and because global scope is a superset of local scope.

Properties

GlobalFeatureService

Gets the global IFeatureService

Methods

GetOrCreate(IPropertyOwner)

Gets the IFeatureService for the specified scope.

Applies to