views:

53

answers:

3

I think i get the MEF model. But I'm having a hard time seeing if it fit's with what I'm trying to do.

I have an app which will call out to third party plugins to do some video processing. The plugin can be FFMPEG.exe or x264.exe, doesn't matter. The process of calling the plugins is via the ProcessStartInfo (basically through the command line) and passing a bunch of parameters. e.g

ffmpeg.exe -in "c:\vid.avi"  -out "c:\vid.avi" -Xheight 100 -Xwidth 100
or 
x264.exe -in "c:\vid.avi"  -out "c:\vid.avi" -Yheight 100 -Ywidth 100

Its a given that each plugin will have their own parameter sets so is it appropriate to use MEF so the interface will be the same no matter which plugin is used (alebit via a public contract)? If so, must I write a wrapper class for each plugin implementing the contract?

Is this the correct way to use MEF? On one hand I'm trying to make my app extensible by allowing customers to choose their plugins. But really I'm not sure if the MEF is overkill and simply using config files to store the command is a better approach?

+1  A: 

If you have possibility to simply use config files then this will be preferable. It will allow to add or change plugins without recompiling. Also this will give opportunity to power user's to tweak plugins.

Orsol
MEF will allow you to change plugins without compiling...
Tim
@Tim: I meant not to recompilation of core, but recompilation in case of change in plugins module or compilation in case of adding plugin.
Orsol
Yes, you would have to re-compile if you changed any code. You wouldn't have to re-compile to add a plugin. That's the point of plugins!
Tim
Sure, but you need to compile plugin, in our case you have no need to compile anything, so even users could create plugins (but it is not always good).
Orsol
A: 

MEF is a great way to add extensibility to an application. You just have to define an interface in your application, implement that interface in the external component and add an Export attribute to the implementation. Using Import Attribute in your application you can discover the external component. See the documentation for details. If you read this, you have an application running using MEF in less than 2 hours.

Back to the topic: If you are only calling different applications with different arguments I wouldn't go for MEF because it would be a little overkill. However, MEF is fun to work with and if you like to experiment a little you could still use it for your application just for the learning experience.

testalino
I'll second the "for the learning experience" idea!
Tim
A: 

Sounds like MEF is probably overkill for what you want. You're plugins are already external applications and you already have a way to call them. Writing the wrappers just seems like more work!

Tim