Share via


FeatureConnectorAttribute Class

Indicates the type of FeatureConnector<TFeatureProviderType> required to handle the FeatureProvider.

Inheritance Hierarchy

System.Object
  System.Attribute
    Microsoft.Windows.Design.Features.FeatureConnectorAttribute

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
[AttributeUsageAttribute(AttributeTargets.Class, AllowMultiple = true)]
public sealed class FeatureConnectorAttribute : Attribute
[AttributeUsageAttribute(AttributeTargets::Class, AllowMultiple = true)]
public ref class FeatureConnectorAttribute sealed : public Attribute
[<Sealed>]
[<AttributeUsageAttribute(AttributeTargets.Class, AllowMultiple = true)>]
type FeatureConnectorAttribute =  
    class
        inherit Attribute
    end
public final class FeatureConnectorAttribute extends Attribute

The FeatureConnectorAttribute type exposes the following members.

Constructors

  Name Description
Public method FeatureConnectorAttribute Initializes a new instance of the FeatureConnectorAttribute class.

Top

Properties

  Name Description
Public property FeatureConnectorType Gets the type of FeatureConnector<TFeatureProviderType> to instantiate.
Public property TypeId Gets an object that is used to determine unique attributes. (Overrides Attribute.TypeId.)

Top

Methods

  Name Description
Public method Equals Returns a value that indicates whether this instance is equal to a specified object. (Overrides Attribute.Equals(Object).)
Protected method Finalize Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public method GetHashCode Returns the hash code for this instance. (Overrides Attribute.GetHashCode().)
Public method GetType Gets the Type of the current instance. (Inherited from Object.)
Public method IsDefaultAttribute When overridden in a derived class, indicates whether the value of this instance is the default value for the derived class. (Inherited from Attribute.)
Public method Match When overridden in a derived class, returns a value that indicates whether this instance equals a specified object. (Inherited from Attribute.)
Protected method MemberwiseClone Creates a shallow copy of the current Object. (Inherited from Object.)
Public method ToString Returns a string that represents the current object. (Inherited from Object.)

Top

Explicit Interface Implementations

  Name Description
Explicit interface implemetationPrivate method _Attribute.GetIDsOfNames Maps a set of names to a corresponding set of dispatch identifiers. (Inherited from Attribute.)
Explicit interface implemetationPrivate method _Attribute.GetTypeInfo Retrieves the type information for an object, which can be used to get the type information for an interface. (Inherited from Attribute.)
Explicit interface implemetationPrivate method _Attribute.GetTypeInfoCount Retrieves the number of type information interfaces that an object provides (either 0 or 1). (Inherited from Attribute.)
Explicit interface implemetationPrivate method _Attribute.Invoke Provides access to properties and methods exposed by an object. (Inherited from Attribute.)

Top

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

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

FeatureManager

FeatureProvider

FeatureConnector<TFeatureProviderType>

Other Resources

Feature Providers and Feature Connectors

Understanding WPF Designer Extensibility