Public · Protected · Private
MEF catalogs
Type: Public  |  Created: 2012-08-29  |  Frozen: Yes
« Previous Public Blog Next Public Blog »
Comments

  • Directory Catalog
    var container =     new CompositionContainer( 
                new DirectoryCatalog(Environment.CurrentDirectory));

    Assembly Catalog
    var catalog = new AssemblyCatalog(System.Reflection.Assembly.GetExecutingAssembly());

    Aggregate Catalog
    var catalog = new AggregateCatalog(
                   new AssemblyCatalog(System.Reflection.Assembly.GetExecutingAssembly()),
                   new DirectoryCatalog(Environment.CurrentDirectory));

    Type Catalog
       var catalog = new TypeCatalog(typeof(WebCache), typeof(AppFabricCache), typeof(MemCache));

    Deployment Catalog -- for silverlight apps to find remote xaps (this may help reduce size of xap for client)
     
    remember: for silverlight use, lighter version of System.ComponentModel.Composition ( version 2.0...or so)

    MEF can reduce the need for third party Dependancy injectors and binders.

     

     

    for layered application with loose coupling between different layers
    Ex: presentation, business, and data access,
    then you should consider using DI and IOC.  -- PRISM, UNITY,Ninject etc...

    For building a scenario such as a logging, caching, and composition application,
    and want to replace assemblies at runtime, consider using MEF.

    2012-08-29 11:26
This blog is frozen. No new comments or edits allowed.