New Posts New Posts RSS Feed: Dynamic discovery, MEF, Prism, etc
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Dynamic discovery, MEF, Prism, etc

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

Joined: 22-Jun-2009
Location: Charlotte
Posts: 112
Post Options Post Options   Quote midnit Quote  Post ReplyReply Direct Link To This Post Topic: Dynamic discovery, MEF, Prism, etc
    Posted: 11-Apr-2011 at 4:44am
I am going to have several questions on this topic...
 
I have code which downloads a xap and all its dependencies and I can sucessfully navigate to a view in that xap and the "module" works as expected as long as I don't make our model ALC compaible - so its in the xap. Ok, so this is due to Devforces composition - all I need to do is tell it to recompose. The problem I am currently having is that when I call
IdeaBlade.Core.Composition.CompositionHost.Add(uri) Devforce(mef) is downloading the xap again, its not using the one I already downloaded - therefore it never downloads the model before recomposing. I have used the same Uri to download the xap and references before calling CompositionHost.Add - why is it downloading it again?
 
I had assumed that since the module was usable that is was downloaded and registered appropriately on the client. If I include the model in the xap then I never have to call CompositionHost.Add and it never downloads the xap twice and it all just works, if the model is not in the xap via ALC then it doesn't know the types...but it still runs. So, doing CompositionHost.Add should recompose it and just work...right? What am I missing here.
Back to Top
midnit View Drop Down
Senior Member
Senior Member
Avatar

Joined: 22-Jun-2009
Location: Charlotte
Posts: 112
Post Options Post Options   Quote midnit Quote  Post ReplyReply Direct Link To This Post Posted: 12-Apr-2011 at 6:10am
Is there a way to add my own parts? Using the CompositionHost.Add(uri) is not meeting my needs. Of course if you could give me a clue as to why its not seeing what I already have in hand.
 
I download the xap, check the manifest and get the list of externalparts, download them and each one uses AssemplyPart.Load (yes on UI thread) to add it to the app domain. So I have, in-hand, a list of all the assemblies needed by the xap and each one should be loaded into the app domain.
 
When thats done I want to tell DevForce to look at what I have and recompose itself but it appears to be downloading the xap (according to fiddler) and of course it does not pull the externalparts so the recomposition does not have all the stuff it needs.
 
So...
1. Is there something that would cause the uri's to not evaluate as the same?
2. Will DevForce simply not use an assembly if its not in the xap? (even though its in the appdomain)
3. Can I add assemblies to the deforce catalog via code?
 
Thoughts?
Back to Top
kimj View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 09-May-2007
Posts: 1391
Post Options Post Options   Quote kimj Quote  Post ReplyReply Direct Link To This Post Posted: 12-Apr-2011 at 9:58am
The CompositionHost.Add(uri) overload may download the XAP again, depending on whether the browser has cached the XAP. Prism (and MEF too) don't provide means of exposing the already downloaded XAP, so there's no convenient way of telling DevForce about the module, other than doing an Add(uri) or Add(catalog). In testing with the Prism v4 Modularity example, the XAP always appeared to be re-downloaded when running with Cassini, but was cached as expected and not re-downloaded once deployed to IIS.
Any of the CompostionHost.Add overloads will look at only the AssemblyParts in the new XAP and load those assemblies into the main container. Any new domain models and known types will also be found from those assemblies. ExternalParts aren't loaded or probed. That means that your models or any other assemblies having composable parts shouldn't be marked for ALC in order for DevForce to find them. Using ALC is best for "library" assemblies, such as the IdeaBlade and System assemblies. A "module" can be fairly granular though - if you've seen the DevForce-Prism Modularity sample you've seen that those modules are simplistic, and could contain only an entity model if wanted.
If you need or want to manually download the external part assemblies, once you've obtained an assembly you can load it into an AssemblyCatalog or AggregateCatalog and pass that to CompositionHost.Add. DevForce will recompose in the same way whether given a catalog or a XAP. To create a catalog from an assembly is easy -
   var assemblyCatalog = new AssemblyCatalog(assembly);
Back to Top
midnit View Drop Down
Senior Member
Senior Member
Avatar

Joined: 22-Jun-2009
Location: Charlotte
Posts: 112
Post Options Post Options   Quote midnit Quote  Post ReplyReply Direct Link To This Post Posted: 12-Apr-2011 at 1:47pm
Thats good new about Cassini because I had seen other instances where it appeared that a file was being downloaded multiple times.
 
You have given me the missing key! AggregateCatalog of AssemblyCatalogs and everything just works.
 
Recomposition isn't going to work if I have different saveinterceptors, loginmanagers, etc in various modules. I don't have this condition, I was just thinking. What other considerations are there in regards to recomposing with more and more items? How can I remove parts or catalogs or whatever?
Back to Top
kimj View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 09-May-2007
Posts: 1391
Post Options Post Options   Quote kimj Quote  Post ReplyReply Direct Link To This Post Posted: 12-Apr-2011 at 6:57pm
If you're using the CompositionContext to provide contextual discovery you can actually have different save interceptors, login managers, etc.   It might get a bit messy, but you can do it.
 
We don't directly support removing parts.  You can in theory remove a catalog from the container, but we haven't tested this to see what happens.  From the DevForce perspective the primary challenge with dynamic modules is in finding the entity model(s) and rebuilding metadata, and secondarily to find additional interface implementations, which standard MEF will mostly handle.
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down