Considerations when architecting an extensible application using MEF

Posted by Dan Bryant on Stack Overflow See other posts from Stack Overflow or by Dan Bryant
Published on 2010-03-13T15:37:49Z Indexed on 2010/03/13 16:35 UTC
Read the original article Hit count: 368

I've begun experimenting with dependency injection (in particular, MEF) for one of my projects, which has a number of different extensibility points. I'm starting to get a feel for what I can do with MEF, but I'd like to hear from others who have more experience with the technology. A few specific cases:

  1. My main use case at the moment is exposing various singleton-like services that my extensions make use of. My Framework assembly exposes service interfaces and my Engine assembly contains concrete implementations. This works well, but I may not want to allow all of my extensions to have access to all of my services. Is there a good way within MEF to limit which particular imports I allow a newly instantiated extension to resolve?

  2. This particular application has extension objects that I repeatedly instantiate. I can import multiple types of Controllers and Machines, which are instantiated in different combinations for a Project. I couldn't find a good way to do this with MEF, so I'm doing my own type discovery and instantiation. Is there a good way to do this within MEF or other DI frameworks?

I welcome input on any other things to watch out for or surprising capabilities you've discovered that have changed the way you architect.

© Stack Overflow or respective owner

Related posts about wpf

Related posts about MEF