Print Page | Close Window

xap files composition

Printed From: IdeaBlade
Category: Cocktail
Forum Name: Community Forum
Forum Discription: A professional application framework using Caliburn.Micro and DevForce
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=3370
Printed Date: 20-Oct-2020 at 9:16am


Topic: xap files composition
Posted By: illidan
Subject: xap files composition
Date Posted: 02-Apr-2012 at 5:30am
Hello,
In my application I want to create several independent modules (in different assemblies), and load all of them during application startup. Most (if not all) composition frameworks allow to specify list of the parts in some kind of configuration file. My question is: how I do that in coctail? Do you have something ready to use, or i have to implement this functionality by myself?

Thanks in advance.



Replies:
Posted By: illidan
Date Posted: 02-Apr-2012 at 5:35am
P.S. It is a Silverlight application.
P.P.S. You have a bug in you forum, in counting views of topic. Going into the topic and back keeps the count increase.


Posted By: Walid
Date Posted: 02-Apr-2012 at 5:52am
in Coktail, you can use the static method AddXap method from the composition class. 
All the logic is already implemented by Devforce and cocktail. 


-------------


Posted By: illidan
Date Posted: 02-Apr-2012 at 6:23am
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.


Posted By: smi-mark
Date Posted: 02-Apr-2012 at 8:29am
Essentially all you need to do is call Composition.AddXap

See this article for more information http://drc.ideablade.com/xwiki/bin/view/Documentation/cocktail-dynamic-xap


Posted By: mgood
Date Posted: 02-Apr-2012 at 11:17am
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.



Print Page | Close Window