New Posts New Posts RSS Feed: Best practice for cocktail with an application loading dynamic XAP
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Best practice for cocktail with an application loading dynamic XAP

 Post Reply Post Reply
Author
Walid View Drop Down
Senior Member
Senior Member
Avatar

Joined: 14-Nov-2010
Posts: 161
Post Options Post Options   Quote Walid Quote  Post ReplyReply Direct Link To This Post Topic: Best practice for cocktail with an application loading dynamic XAP
    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,
Back to Top
mgood View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 18-Nov-2010
Location: Emeryville, CA
Posts: 583
Post Options Post Options   Quote mgood Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
Walid View Drop Down
Senior Member
Senior Member
Avatar

Joined: 14-Nov-2010
Posts: 161
Post Options Post Options   Quote Walid Quote  Post ReplyReply Direct Link To This Post 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 ?


Back to Top
mgood View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 18-Nov-2010
Location: Emeryville, CA
Posts: 583
Post Options Post Options   Quote mgood Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
Walid View Drop Down
Senior Member
Senior Member
Avatar

Joined: 14-Nov-2010
Posts: 161
Post Options Post Options   Quote Walid Quote  Post ReplyReply Direct Link To This Post Posted: 09-Mar-2012 at 1:17am
ok got it. Thank you
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down