Export (0) Print
Expand All

FeatureManager Class

Manages feature providers and feature connectors.

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

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

public class FeatureManager : IDisposable

The FeatureManager type exposes the following members.

  NameDescription
Public methodFeatureManagerInitializes a new instance of the FeatureManager class.
Top

  NameDescription
Public propertyContextGets the editing context for this feature manager.
Public propertyMetadataProviderGets or sets a custom metadata provider that can provide type metadata for this feature manager.
Public propertyPendingConnectorsGets an enumeration of all connectors that have not been activated yet because they are waiting on context items or services.
Public propertyRunningConnectorsGets an enumeration of all connectors that are currently running.
Top

  NameDescription
Public methodCreateFeatureProviders(Type)Creates and returns a set of feature providers for the specified type.
Public methodCreateFeatureProviders(Type, Predicate<Type>)Creates and returns a set of feature providers for the specified type.
Public methodCreateFeatureProviders(Type, Type)Creates and returns a set of feature providers that exist for the specified type.
Public methodCreateFeatureProviders(Type, Type, Predicate<Type>)Creates and returns a set of feature providers that exist for the specified type.
Public methodDispose()Releases all resources used by the FeatureManager.
Protected methodDispose(Boolean)Disposes all running feature connectors.
Public methodEqualsDetermines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected methodFinalizeFinalizer that calls Dispose. (Overrides Object.Finalize().)
Public methodGetCustomAttributesEnumerates attributes on the specified type.
Public methodGetHashCodeServes as a hash function for a particular type. (Inherited from Object.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Public methodInitializeFeaturesInitializes any feature connectors for the feature providers defined on the specified type.
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Protected methodOnFeatureAvailableRaises the FeatureAvailable event.
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)
Top

  NameDescription
Public eventFeatureAvailableOccurs when a new type of feature is available.
Top

  NameDescription
Public Extension MethodCreateFeatureProviders(Type, ModelItem)Overloaded. Creates feature providers of the specified type and model item. (Defined by FeatureExtensions.)
Public Extension MethodCreateFeatureProviders(Type, ModelItem, Predicate<Type>)Overloaded. Creates feature providers of the specified type and model item. (Defined by FeatureExtensions.)
Top

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.

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 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);
    }
}


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

Community Additions

ADD
Show:
© 2014 Microsoft