FeatureConnector<TFeatureProviderType> Class
Provides a base implementation for all feature connector-based extensibility.
Namespace: Microsoft.Windows.Design.Features
Assembly: Microsoft.Windows.Design.Extensibility (in Microsoft.Windows.Design.Extensibility.dll)
Syntax
'Declaration
Public MustInherit Class FeatureConnector(Of TFeatureProviderType As FeatureProvider) _
Implements IDisposable
'Usage
Dim instance As FeatureConnector(Of TFeatureProviderType)
public abstract class FeatureConnector<TFeatureProviderType> : IDisposable
where TFeatureProviderType : FeatureProvider
generic<typename TFeatureProviderType>
where TFeatureProviderType : FeatureProvider
public ref class FeatureConnector abstract : IDisposable
JScript does not support generic types or methods.
Type Parameters
- TFeatureProviderType
The type of feature provider.
Remarks
Derive from the abstract FeatureConnector<TFeatureProviderType> class when you need to implement the deepest level of integration with the WPF Designer. Feature connectors can subscribe to global services and can add their own services.
Feature providers use FeatureConnectorAttribute to specify the associated feature connector.
The FeatureConnector<TFeatureProviderType> base class is generic and consumes the type of the feature provider that the FeatureConnector<TFeatureProviderType> hosts.
Feature connectors are demand-created. When the FeatureManager class discovers a FeatureConnectorAttribute on a FeatureProvider, it creates the specified FeatureConnector<TFeatureProviderType>, if it does not already exist.
The abstract FeatureConnector<TFeatureProviderType> class implements the IDisposable interface, which promotes a simple cleanup implementation.
Most of the functionality of the FeatureConnector<TFeatureProviderType> class is implemented in the protected CreateFeatureProviders method. Passing an object into this method causes the feature connector to search for FeatureAttribute types on the object. If these attributes are found, the FeatureProvider instance associated with each attribute is created and returned in a list.
Examples
The following code example shows how to derive from the FeatureConnector<TFeatureProviderType> class to connect a custom feature provider named DiagnosticsMenuProvider with a custom service named IDiagnosticsService. For a complete code listing, see How to: Create a Custom Feature Connector.
' The IDiagnosticsService specifies a simple interface for showing
' a FeatureManagerDiagnostics window.
Interface IDiagnosticsService
Sub ShowWindow()
End Interface
...
' The DiagnosticsFeatureConnector publishes the IDiagnosticsService.
Class DiagnosticsFeatureConnector
Inherits FeatureConnector(Of DiagnosticsMenuProvider)
Implements IDiagnosticsService
Dim fmdWindow As FeatureManagerDiagnostics
Public Sub New(ByVal manager As FeatureManager)
MyBase.New(manager)
Context.Services.Publish(Of IDiagnosticsService)(Me)
End Sub
' The showWindow method creates a FeatureManagerDiagnostics
' window and shows it.
Public Sub ShowWindow() Implements IDiagnosticsService.ShowWindow
If fmdWindow IsNot Nothing Then
' Show the FeatureManagerDiagnostics window.
fmdWindow.Show()
' Activate the
fmdWindow.Activate()
Else
fmdWindow = New FeatureManagerDiagnostics()
fmdWindow.Initialize(Manager)
AddHandler fmdWindow.Closed, AddressOf fmdWindow_Closed
fmdWindow.Show()
End If
End Sub
Sub fmdWindow_Closed(ByVal sender As Object, ByVal e As EventArgs)
fmdWindow = Nothing
End Sub
End Class
// The IDiagnosticsService specifies a simple interface for showing
// a FeatureManagerDiagnostics window.
interface IDiagnosticsService
{
void ShowWindow();
}
...
// The DiagnosticsFeatureConnector publishes the IDiagnosticsService.
class DiagnosticsFeatureConnector : FeatureConnector<DiagnosticsMenuProvider>,
IDiagnosticsService
{
FeatureManagerDiagnostics fmdWindow;
public DiagnosticsFeatureConnector(FeatureManager manager)
: base(manager)
{
Context.Services.Publish<IDiagnosticsService>(this);
}
#region IDiagnosticsService Members
// The showWindow method creates a FeatureManagerDiagnostics
// window and shows it.
public void ShowWindow()
{
if (fmdWindow != null)
{
fmdWindow.Show();
fmdWindow.Activate();
}
else
{
fmdWindow = new FeatureManagerDiagnostics();
fmdWindow.Initialize(Manager);
fmdWindow.Closed += new EventHandler(fmdWindow_Closed);
fmdWindow.Show();
}
}
void fmdWindow_Closed(object sender, EventArgs e)
{
fmdWindow = null;
}
#endregion
}
Inheritance Hierarchy
System.Object
Microsoft.Windows.Design.Features.FeatureConnector<TFeatureProviderType>
Microsoft.Windows.Design.Features.PolicyDrivenFeatureConnector<TFeatureProviderType>
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
FeatureConnector<TFeatureProviderType> Members
Microsoft.Windows.Design.Features Namespace
Other Resources
How to: Create a Custom Feature Connector