views:

48

answers:

1

Hi!

I'm using MEF for a plugin-system to my application. The flow goes like this:

  1. Run all Pre-plugins
  2. Run all Core-plugins
  3. Run all Post-plugins

For example, if a plugin in the Core execution fails, i don't want to run certain post plugins.

What would be the best way to achieve this? Hope my question is clear, otherwise please tell me and i'll try to elaborate.

+1  A: 

Have your core plugins return to an interface, say IResult which has your return values and an error status. Pass the error statuses into your Post plugins thru the constructor, or as part of the contract method signature, and allow your plugin to decide whether it runs or not.

Otherwise it sounds like the app itself is making decisions on whether plugins are running or not, and that defeats the purpose of the whole plugin architecture.

Even so, it sounds more like you have pre-run-post event processing going on here, so why not just set up events that can be subscribed to by your plugins, and group the pre, core and post processing logically into the plugins. They can maintain their own internal state then and decide when to run the post processing based on the success or failure of your core processing.

pms1969