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 | |
---|---|---|
FeatureManager | Initializes a new instance of the FeatureManager class. |
Top
Properties
Name | Description | |
---|---|---|
Context | Gets the editing context for this feature manager. | |
MetadataProvider | Gets or sets a custom metadata provider that can provide type metadata for this feature manager. | |
PendingConnectors | Gets an enumeration of all connectors that have not been activated yet because they are waiting on context items or services. | |
RunningConnectors | Gets an enumeration of all connectors that are currently running. |
Top
Methods
Name | Description | |
---|---|---|
CreateFeatureProviders(Type) | Creates and returns a set of feature providers for the specified type. | |
CreateFeatureProviders(Type, Predicate<Type>) | Creates and returns a set of feature providers for the specified type. | |
CreateFeatureProviders(Type, Type) | Creates and returns a set of feature providers that exist for the specified type. | |
CreateFeatureProviders(Type, Type, Predicate<Type>) | Creates and returns a set of feature providers that exist for the specified type. | |
Dispose() | Releases all resources used by the FeatureManager. | |
Dispose(Boolean) | Disposes all running feature connectors. | |
Equals | Determines whether the specified Object is equal to the current Object. (Inherited from Object.) | |
Finalize | Finalizer that calls Dispose. (Overrides Object.Finalize().) | |
GetCustomAttributes | Enumerates attributes on the specified type. | |
GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.) | |
GetType | Gets the Type of the current instance. (Inherited from Object.) | |
InitializeFeatures | Initializes any feature connectors for the feature providers defined on the specified type. | |
MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) | |
OnFeatureAvailable | Raises the FeatureAvailable event. | |
ToString | Returns a string that represents the current object. (Inherited from Object.) |
Top
Events
Name | Description | |
---|---|---|
FeatureAvailable | Occurs when a new type of feature is available. |
Top
Extension Methods
Name | Description | |
---|---|---|
CreateFeatureProviders(Type, ModelItem) | Overloaded. Creates feature providers of the specified type and model item. (Defined by FeatureExtensions.) | |
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
FeatureConnector<TFeatureProviderType>
Other Resources
How to: Create a Custom Feature Connector