Originally posted by illidan
AddXap exist from the beginning in MEF. The question is, do I have to implement the code which is going to configuration file, loads all file names and passing them to AddXap method, or coctail team provide something like this out of box. |
No, there isn't currently anything prebuilt to eager load your modules based on a configuration file. AddXap provides the low level functionality of loading the XAP, that goes further than the standard MEF DeploymentCatalog. With Composition.AddXap you can actually have entire new domain models in the XAP you are loading and they get properly discovered and initialized. It also makes sure that the underlying ViewLocator is made aware of the new assemblies that might contain views.
Cocktail follows the convention-over-configuration principal. We rarely eager load modules. The application logic/flow should be in charge of loading a XAP when it's actually needed and not way in advance when it might never be used.
Having said that, occasionally the need arises to eager load certain modules during startup, but Cocktail currently leaves that up to the developer for how she wants to do this. The hooks are there. For example you can overload FrameworkBootstrapper.StartRuntimeAsync to perform the eager loading as part of the application's bootstrapping.
Just keep in mind that eager loading anything delays the application startup. Breaking an application into multiple XAPs is intended to speed up said startup and reduce the initial download size. Eager loading the modules kinda defeats that and the more XAPs you eager load the higher the overhead due to the multiple downloads that get initiated. It generally leads to a better user experience to defer loading. You could load in the background, but then you have to implement ugly logic that prevents the user from entering a certain module until it's loaded completely.
Just a few thoughts to ponder.
Edited by DFFadmin - 02-Apr-2012 at 11:45am