FeatureConnectorAttribute 類別
更新:2007 年 11 月
表示需要用來處理 FeatureProvider 之 FeatureConnector<TFeatureProviderType> 的型別。
命名空間: Microsoft.Windows.Design.Features
組件: Microsoft.Windows.Design.Extensibility (在 Microsoft.Windows.Design.Extensibility.dll 中)
語法
<AttributeUsageAttribute(AttributeTargets.Class, AllowMultiple := True)> _
Public NotInheritable Class FeatureConnectorAttribute _
Inherits Attribute
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
備註
您可以將 FeatureConnectorAttribute 套用至自訂 FeatureProvider 類別,以指定會發行 FeatureProvider 所需之服務的 FeatureConnector<TFeatureProviderType>。
範例
在下列程式碼範例中,會說明如何使用 FeatureConnectorAttribute,讓 FeatureConnector<TFeatureProviderType> 類別與名為 DiagnosticsMenuProvider 的功能提供者產生關聯。如需完整的程式碼清單,請參閱 HOW TO:建立自訂功能連接器。
' 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();
}
}
繼承階層架構
System.Object
System.Attribute
Microsoft.Windows.Design.Features.FeatureConnectorAttribute
執行緒安全
這個型別的任何 Public static (在 Visual Basic 中為 Shared) 成員都具備執行緒安全。並非所有的執行個體成員都是安全執行緒。
請參閱
參考
Microsoft.Windows.Design.Features 命名空間
FeatureConnector<TFeatureProviderType>