Print Page | Close Window

Best practice for cocktail with an application loading dynamic XAP

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=3306
Printed Date: 28-Mar-2024 at 7:36am


Topic: Best practice for cocktail with an application loading dynamic XAP
Posted By: Walid
Subject: Best practice for cocktail with an application loading dynamic XAP
Date Posted: 28-Feb-2012 at 1:47pm
Hi,
 
I try to implement some of the Cocktail's concept in my application but I don't really know what is the best way to do it.
 
I have an application which dynamically load its modules (XAP). Each module consist of 3 assemblies (one for the model, one for the screens/viewmodels and the last one for the repository stufff).
 
- Is having the EntityManagerProviders/SampleDataProvider in the Silverlight Model assembly a good practice (this is actually where I put them) ?
- The application does know about the existance of the EntityManagerProvider only after the one of those XAP is loaded. So where (and how) can I put the lookuprepository initialization ?
- Same problem for the ISampleDataProvider ...
 
I tried differents ways but none looks very good.
Maybe have a class dedicated to Initialization which could be triggered right after a XAP is loaded ? but how to get an instance of it thru MEF since the main application doesn't know the type of T ?
 
I was thinking of something like this :
 
[Export]
public class InitializeModel<T>
{
  [ImportMany]
  public IEnumerable<IEntityManagerProvider<T>> entityManagerProvider;
  [ImportMany]
   public IEnumerable<IDataSampleProvider<T>> dataSampleProvider;
 
   public INotifyCompleted Initialize(){};
 
}
 
 
 
What is for you the best practice for this kind of problem ?
 
 
Regards,



Replies:
Posted By: mgood
Date Posted: 28-Feb-2012 at 2:36pm
I would not put anything in the model assembly, other than the model. If you add EMPs and SampleDataProviders to the model, you have a dependency to Cocktail, which in turn has a dependency to Caliburn.Micro. You don't want all that in the model. If you look at TempHire, the model assembly is simply the model. The other things sit in the Common.SL assembly or TempHire.SL.
As for the initialization, you can define an initializer interface and have an implementation in each XAP and then export it via the initializer interface. The main application when it loads a new XAP, after the loading finishes it looks for the new initializer in the MEF container and calls a method on it. Your initializer implementation then knows what T is. It would be all hidden behind the initializer that goes with the XAP.


Posted By: Walid
Date Posted: 08-Mar-2012 at 1:29pm
Ok thanks.

what about the EntityServerQueryInterceptor, EntityServerSaveInterceptor, ect ...
is it ok to put them in the Domain assembly or should I have a dedicated Services assembly for them ?




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


Posted By: mgood
Date Posted: 08-Mar-2012 at 7:49pm
You can put them in the domain assembly as long as they don't depend on anything that you don't have access to in the domain assembly and that doesn't introduce another dependency that the domain assembly shouldn't have.


Posted By: Walid
Date Posted: 09-Mar-2012 at 1:17am
ok got it. Thank you

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



Print Page | Close Window