Composition

TfsWorkbench.WpfUI.Controllers.ApplicationController.Compose() is responsible for importing and composing all plugins.

The ImportMany attribute on the following fields allows the composition to take place since each one of the DisplayMode and WorkbenchPlugin types in the external libraries is attributed with a matching Export.
 [ImportMany]
 private readonly ICollection<IDisplayMode> displayModes;
 [ImportMany]
 private readonly ICollection<IWorkbenchPlugin> plugins

The DataProvider type is treated a little differently. It is explicitly pulled out of the composition container. By using the GetExport() method, only one DataProvider export is allowed.
This leads me to believe that multiple data providers are not currently supported.
Lazy<IDataProvider> export = container.GetExport<IDataProvider>();

more on data provider...
Project Data Helper
Project Data Controller

RegisterDisplayModes(IDataProvider)
  1. Display mode collection is sorted by display priority
  2. Collection is then iterated
    1. Mode is assigned the data provider passed into this method.
    2. IDisplayMode is cast to UIElement and added to the main window's editor (owner: WpfUI.MainAppWindow.PART_DisplayModeGrid)
    3. The mode title is added to the upper portion of the main window as a DisplayModeTitle type (owner: WpfUI.Controls.TitleControl.PART_ItemsControl)
    4. If the mode has a menu item then that item is added to the main window's View menu (owner: WpfUI.MainAppWindow.MainMenu.PART_ViewMenu)
    5. If the mode implements IHighlightProvider then it is added to the search provider service (owner: Core.ProjectDataHelper.SearchProviders)
  3. Highest priority mode is activated and displayed to user.

RegisterPlugins()
  1. Plugin collection is sorted by display priority
  2. Collection is then iterated
    1. All of the plugin's commands are registered with the main application's command controller ( what are WPF routed commands? )
    2. If the plugin has a menu item then that menu item is added to the main window's Tools menu (owner: WpfUI.MainAppWindow.PART_PlugInMenu)
    3. If the plugin has a user control then that control is added to the main window's lower status bar (owner: WpfUI.MainAppWindow.PART_PlugInPanel)

Last edited Jan 29, 2011 at 3:07 AM by fixitchris, version 12