Best practices for using MEF's RegistrationBuilder with Prism

Nov 1, 2014 at 3:44 PM
Edited Nov 1, 2014 at 3:47 PM
I'm not finding any guidance on how to implement MEF's RegistrationBuilder (Convention model) in Prism - can you provide an example of a best pattern and practice for this?

Below, in my POC, I implement what little documentation I can find on the convention model topic to successfully execute imported commands but only if I manually satisfy imports.
        public IEnumerable<ICommand> Commands { get; set; }

        protected override void ConfigureAggregateCatalog()

            // Add this class 
                   .Add(new AssemblyCatalog(typeof(QuickStartBootstrapper).Assembly));

            // Add the AddIns folder 
            var catalog = new DirectoryCatalog("AddIns");

            // Export all ICommand values and import them into the Commands property
            var conventions = new RegistrationBuilder();
                    .ImportProperty<ICommand>(p => p.Commands);

            var thisAssemblyCatalog = new 
                AssemblyCatalog(typeof (CallbackLogger).Assembly, conventions);


            using (var service = thisAssemblyCatalog.CreateCompositionService())
                service.SatisfyImportsOnce(this, conventions);
                foreach (var command in Commands)
                    if (command.CanExecute(moduleManager))

Nov 4, 2014 at 3:02 PM
My recent blog on "a way" for How to use MEF's convention model in PRISM
Marked as answer by BillKrat on 11/4/2014 at 7:02 AM