[I have read previous posts on MEF vs MAF vs DI etc, they aren’t helping me with my specific problem]
I am looking to write a .Net application (probably console or Windoes service) which will be extensible. It is an overnight/schedule app to extract data from a database, do something with it, and then output it (or pass it on to another system).
I am unsure what the best way to define this process for plugins. The components are:
- Task – definition of the actual task, containing plugin definitions, and event based flag on when to run (EOD,EOW,EOM)
- Source – the source of the data (a task will have one to many sources), this could be a SQL query/stored proc, web service, or perhaps a file. I see this outputting a datatable.
- PostProcess – the processing required to be done on the Source output (a task will have none to many post process steps), this could be an aggregator or some sort of specific processing). This would receive a dataset (containing the data table/s from the previous step). These would have to run in a specific order due to dependancies.
- Target – the end result (also one to many), this could be a SQL statement/stored proc, a proprietary data load, email, output file or a web service
To simplify it I would prefer that the plugins could read from the config file, this would mean I wont need to know what connection strings (and other details) to pass to plugins.
I have looked at MEF, MAF, DI, or just defining my own framework. At this stage I am leaning towards developing my own, just wondered if I had missed anything?
I would actually like to use MEF, however as I need to define my task (ie. Task links to which Sources links to which PostProcess links to which Target), and also not having access to config. I have seen MEF Primatives and Type Catalogs get me part of the way, but doesn’t seem to help my chaining of plugins. Is MEF a valid choice?
MEF is definitely a valid choice. However, I dont think MEF was designed to be a fully fledged plug-in system, it is intended as a good starting point! MEF handles all the dirty assembly loading and disposing, but any specific pre-requisites need to checked manually. For this I would recommend using metadata. Metadata allows you to associate information with exports that can be read before you import them (MEF Metadata)
Passing the config through with MEF is simple. The host application can export its self and all the plugins import it and have access to its interface. See my example below:
Interface:
Host App:
Plug-in assembly: