FeatureManager Class

Manages feature providers and feature connectors.

Inheritance Hierarchy

System.Object
  Microsoft.Windows.Design.Features.FeatureManager

Namespace:  Microsoft.Windows.Design.Features
Assembly:  Microsoft.Windows.Design.Extensibility (in Microsoft.Windows.Design.Extensibility.dll)

Syntax

'Declaration
Public Class FeatureManager _
    Implements IDisposable
public class FeatureManager : IDisposable
public ref class FeatureManager : IDisposable
type FeatureManager =  
    class
        interface IDisposable
    end
public class FeatureManager implements IDisposable

The FeatureManager type exposes the following members.

Constructors

  Name Description
Public method FeatureManager Initializes a new instance of the FeatureManager class.

Top

Properties

  Name Description
Public property Context Gets the editing context for this feature manager.
Public property MetadataProvider Gets or sets a custom metadata provider that can provide type metadata for this feature manager.
Public property PendingConnectors Gets an enumeration of all connectors that have not been activated yet because they are waiting on context items or services.
Public property RunningConnectors Gets an enumeration of all connectors that are currently running.

Top

Methods

  Name Description
Public method CreateFeatureProviders(Type) Creates and returns a set of feature providers for the specified type.
Public method CreateFeatureProviders(Type, Predicate<Type>) Creates and returns a set of feature providers for the specified type.
Public method CreateFeatureProviders(Type, Type) Creates and returns a set of feature providers that exist for the specified type.
Public method CreateFeatureProviders(Type, Type, Predicate<Type>) Creates and returns a set of feature providers that exist for the specified type.
Public method Dispose() Releases all resources used by the FeatureManager.
Protected method Dispose(Boolean) Disposes all running feature connectors.
Public method Equals Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected method Finalize Finalizer that calls Dispose. (Overrides Object.Finalize().)
Public method GetCustomAttributes Enumerates attributes on the specified type.
Public method GetHashCode Serves as a hash function for a particular type. (Inherited from Object.)
Public method GetType Gets the Type of the current instance. (Inherited from Object.)
Public method InitializeFeatures Initializes any feature connectors for the feature providers defined on the specified type.
Protected method MemberwiseClone Creates a shallow copy of the current Object. (Inherited from Object.)
Protected method OnFeatureAvailable Raises the FeatureAvailable event.
Public method ToString Returns a string that represents the current object. (Inherited from Object.)

Top

Events

  Name Description
Public event FeatureAvailable Occurs when a new type of feature is available.

Top

Extension Methods

  Name Description
Public Extension Method CreateFeatureProviders(Type, ModelItem) Overloaded. Creates feature providers of the specified type and model item. (Defined by FeatureExtensions.)
Public Extension Method CreateFeatureProviders(Type, ModelItem, Predicate<Type>) Overloaded. Creates feature providers of the specified type and model item. (Defined by FeatureExtensions.)

Top

Remarks

Use the FeatureManager class to create feature providers and to query for running and pending feature connectors.

If a feature connector needs to be instantiated, but it subscribes either to services or to context items that do not yet exist, the connector type is put on a pending list and subscriptions are added to the editing context. When the correct services and items become available, the feature connector is instantiated.

When an object is added to an editing model, the editing model should call the InitializeFeatures method on the feature manager, which inspects the object for feature attributes. It follows these attributes to FeatureConnector<TFeatureProviderType> attributes and makes sure that all unique connectors have been instantiated.

Examples

The following sample code shows how to use the FeatureManager class to access the running and pending connectors. For a complete code listing, see How to: Create a Custom Feature Connector.

Public Sub Initialize(ByVal manager As FeatureManager)
    featManager = manager
    Bind()
End Sub


...


' Binds the activatedFeatures and pendingFeatures controls
' the FeatureManager's RunningConnectors and PendingConnectors\
' properties.
Private Sub Bind()
    activatedFeatures.Items.Clear()
    pendingFeatures.Items.Clear()

    Dim info As FeatureConnectorInformation
    For Each info In featManager.RunningConnectors
        activatedFeatures.Items.Add(info)
    Next info

    For Each info In featManager.PendingConnectors
        pendingFeatures.Items.Add(info)
    Next info

End Sub
public void Initialize(FeatureManager manager) 
{
    featManager = manager;
    Bind();
}


...


// Binds the activatedFeatures and pendingFeatures controls
// the FeatureManager's RunningConnectors and PendingConnectors\
// properties.
private void Bind() 
{
    activatedFeatures.Items.Clear();
    pendingFeatures.Items.Clear();

    foreach (FeatureConnectorInformation info in 
        featManager.RunningConnectors) 
    {
        activatedFeatures.Items.Add(info);
    }

    foreach (FeatureConnectorInformation info in 
        featManager.PendingConnectors) 
    {
        pendingFeatures.Items.Add(info);
    }
}

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See Also

Reference

Microsoft.Windows.Design.Features Namespace

FeatureProvider

FeatureConnector<TFeatureProviderType>

Other Resources

How to: Create a Custom Feature Connector

Feature Providers and Feature Connectors

Understanding WPF Designer Extensibility