Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

FeatureConnector<TFeatureProviderType> Class

Provides a base implementation for all feature connector-based extensibility.

System.Object
  Microsoft.Windows.Design.Features.FeatureConnector<TFeatureProviderType>
    Microsoft.Windows.Design.Policies.PolicyDrivenFeatureConnector<TFeatureProviderType>

Namespace:  Microsoft.Windows.Design.Features
Assembly:  Microsoft.Windows.Design.Extensibility (in Microsoft.Windows.Design.Extensibility.dll)

public abstract class FeatureConnector<TFeatureProviderType> : IDisposable
where TFeatureProviderType : FeatureProvider

Type Parameters

TFeatureProviderType

The type of feature provider.

The FeatureConnector<TFeatureProviderType> type exposes the following members.

  NameDescription
Protected methodFeatureConnector<TFeatureProviderType>Initializes a new instance of the FeatureConnector<TFeatureProviderType> class.
Top

  NameDescription
Protected propertyContextGets the editing context for the feature connector.
Protected propertyManagerGets the FeatureManager for the feature connector.
Top

  NameDescription
Protected methodCreateFeatureProviders(Type)Creates a new list of feature providers associated with the feature connector, based on the provided type.
Protected methodCreateFeatureProviders<TSubtype>(Type)Creates a new list of feature providers associated with the feature connector, based on the provided type and subtype.
Public methodDispose()Releases all resources used by the FeatureConnector<TFeatureProviderType>.
Protected methodDispose(Boolean)Releases the unmanaged resources used by the FeatureConnector<TFeatureProviderType> and optionally releases the managed resources.
Public methodEqualsDetermines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Overrides Object.Finalize().)
Public methodGetHashCodeServes as a hash function for a particular type. (Inherited from Object.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)
Top

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 methods. 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.

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 
{
    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
}


Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Community Additions

ADD
Show:
© 2015 Microsoft