This project has moved. For the latest updates, please go here.


1. Overview

This class provides a generic AdapterFactoryCatalog service. This service is based on the idea of the UIElementAdapterFactoryCatalog which is part of the Composite UI Application Block. CAB uses the UIElementAdapterFactoryCatalog during the registration of new UI elements as UIExtensionSites:

presenter.WorkItem.UIExtensionSites.RegisterSite(UIExtensionSiteNames.MainMenu, mainMenuStrip);

The RegisterSite method tries to retrieve an adequate adapter factory from the catalog. With the adapter factory it creates a new adapter for the "mainMenuStrip" to match the IUIElementAdapter interface. After this step the "mainMenuStrip" can be used as UIExtensionSite through the adapter. One advantage of this strategy is that the developer does not need to care about instantiating the correct adapter for the "mainMenuStrip".

The same principle is used in the Test Suite reference application for the EditManager implementation. However this implementation uses the generic AdapterFactoryCatalog of this library. Figure 1 shows a class diagram of the generic AdapterFactoryCatalog implementation:

Figure 1

  • IAdapterFactoryCatalog: The interface of the AdapterFactoryCatalog class. This interface is used to register and retrieve the catalog as a CAB service.
  • AdapterFactoryCatalog: The generic adapter factory catalog implementation.
  • IAdapterFactory: This interface needs to be implemented by the adapter factories.
Note: The AdapterFactoryCatalog iterates the factory list from last to first. Later registered factories are able to overwrite the already registered factories. This behavior is different to the one of the UIElementAdapterFactoryCatalog.

2. Example

The following example shows how the AdapterFactoryCatalog is used in the Test Suite application.

Configuration of the AdapterFactoryCatalog:

public override void AddServices()
    factoryCatalog = rootWorkItem.Services.AddNew<AdapterFactoryCatalog<IEditHandler>, 

public override void Load()
    factoryCatalog.RegisterFactory(new TextBoxAdapterFactory());

Usage of the AdapterFactoryCatalog service:

public IAdapterFactoryCatalog<IEditHandler> FactoryCatalog
    set { factoryCatalog = value; }

public void Register(object uiElement)
    IEditHandler handler = factoryCatalog.GetFactory(uiElement).GetAdapter(uiElement);

Last edited Oct 8, 2007 at 1:30 PM by jbe2277, version 12


No comments yet.