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,