FeatureConnectorAttribute Class
Indicates the type of FeatureConnector<TFeatureProviderType> required to handle the FeatureProvider.
Namespace: Microsoft.Windows.Design.Features
Assembly: Microsoft.Windows.Design.Extensibility (in Microsoft.Windows.Design.Extensibility.dll)
Syntax
'Declaration
<AttributeUsageAttribute(AttributeTargets.Class, AllowMultiple := True)> _
Public NotInheritable Class FeatureConnectorAttribute _
Inherits Attribute
'Usage
Dim instance As FeatureConnectorAttribute
[AttributeUsageAttribute(AttributeTargets.Class, AllowMultiple = true)]
public sealed class FeatureConnectorAttribute : Attribute
[AttributeUsageAttribute(AttributeTargets::Class, AllowMultiple = true)]
public ref class FeatureConnectorAttribute sealed : public Attribute
public final class FeatureConnectorAttribute extends Attribute
Remarks
Apply the FeatureConnectorAttribute to your custom FeatureProvider class to specify a FeatureConnector<TFeatureProviderType> that publishes a service required by your FeatureProvider.
Examples
The following code example shows how to use the FeatureConnectorAttribute to associate a FeatureConnector<TFeatureProviderType> class with a custom feature provider named DiagnosticsMenuProvider. For a complete code listing, see How to: Create a Custom Feature Connector.
' The DiagnosticsMenuProvider class adds a context menu item
' that displays a dialog box listing the currently running and
' pending feature connectors.
<FeatureConnector(GetType(DiagnosticsFeatureConnector))> _
Public Class DiagnosticsMenuProvider
Inherits PrimarySelectionContextMenuProvider
Public Sub New()
Dim action As New MenuAction("Feature Diagnostics...")
AddHandler action.Execute, AddressOf action_Execute
Items.Add(action)
End Sub
Sub action_Execute(ByVal sender As Object, ByVal e As MenuActionEventArgs)
Dim service As IDiagnosticsService = e.Context.Services.GetRequiredService(Of IDiagnosticsService)()
service.ShowWindow()
End Sub
End Class
// The DiagnosticsMenuProvider class adds a context menu item
// that displays a dialog box listing the currently running and
// pending feature connectors.
[FeatureConnector(typeof(DiagnosticsFeatureConnector))]
public class DiagnosticsMenuProvider : PrimarySelectionContextMenuProvider
{
public DiagnosticsMenuProvider()
{
MenuAction action = new MenuAction("Feature Diagnostics...");
action.Execute += new EventHandler<MenuActionEventArgs>(action_Execute);
Items.Add(action);
}
void action_Execute(object sender, MenuActionEventArgs e)
{
IDiagnosticsService service =
e.Context.Services.GetRequiredService<IDiagnosticsService>();
service.ShowWindow();
}
}
Inheritance Hierarchy
System.Object
System.Attribute
Microsoft.Windows.Design.Features.FeatureConnectorAttribute
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
FeatureConnectorAttribute Members
Microsoft.Windows.Design.Features Namespace
FeatureConnector<TFeatureProviderType>