Modularity.WithUnity.Desktop (Where is the module registration)

Topics: Prism v4 - WPF 4
Sep 11, 2010 at 7:25 AM
Edited Sep 11, 2010 at 7:26 AM

Hi,

Going through the quickstarts and building something along the line to learn prism.

I am surely missing something cannot seem to find how you register the module.

Usually in the constructor of a module I think we should have something like

   private void RegisterViewsAndServices()
        {
            this.Container.RegisterType<IActivityView, ActivityView>();
        }
I have looked in all the modules A,B,C etc... but cannot see how you register them.
Is done in the bootstrapper by the moduleTracker?
Which line of code does the registration? 
Just wanted to learn your approach
Thanks for any feedback
Sep 11, 2010 at 8:30 AM

It depends on what you mean by "registering a module."

If you mean getting the modules in the module catalog, the quickstart's bootstrapper adds the modules in several different ways in the ConfigureModuleCatalog method: A & C are added explicitly, B & D are added via directory sweep, and E & F are added via configuration.  In a real app, you would probably choose only one of these approaches, but we wanted to show all of them being used.  This is what I consider "registering a module".

If you mean registering the UI components from the modules, the quickstart does not do this.  All the UI is in the shell and the ModuleTracker (view model) is notfied of changes in the state of the modules by the modules themselves. All the modules have the ModuleTracker injected into the constructors and they call methods to indicate state changes.  However in a typical app, you would probably use the module's initialize method to dynamically register UI elements (or use a RegisterViews method that is called from Initialize like the one that you describe above).

If you mean registering application-level services from the module with the container, there is only one service ( an IModuleTracker implementation) that is provided by the shell in the bootstrapper.  Again, on a typical app, you would probably use the module's initialize method to register services (or use a RegisterViews method that is called from Initialize like the one that you describe above). 

You may also want to read through the following sections in the CHM file:

  • Chapter 4: Modular Application Development 
    • This explains most of the concepts around modularity you will probably run into in an app. Skim down to the Core Scenarios section if you are in a hurry.
  • Modularity QuickStarts for WPF (updated) -- under Appendix G: QuickStarts 
    • This explains how we built the modularity quickstarts and how modules are created, registered, loaded, etc.

Let us know if you still have questions.

 

Sep 11, 2010 at 8:59 AM
Edited Sep 11, 2010 at 9:28 AM

Thank you very much for detailed explanation

All clear now thanks

My Scenarios are

Registering the UI components from the modules

Registering application-level services from the module with the container

and you fully answered them.

I was a bit intrigued as all the examples I have seen so far on the net the use RegisterViews and Services etc.. like the EventAggregator Example but the modularity one didnt and being new to Prism I had doubts

thanks