I'm getting ready to start a new application.
It will simply read a File (First iteration will be CVS formated files)
then control some external hardware (brand x for now)
Now what I'm wondering is / are their any good examples on how to add a "Plug In" feature to an application. For example you can add "Filters" to Photoshop or tools to Import New Files types.
So my Import Plugin would by default open the CVS File, process it and return the data in a structured format to the main application.
But next month I might need it to open a new file format, and instead of patching / releasing a new version of the software I'd want to just allow a new plugin to be installed.
This would then open the new file format, convert it & return the data to the main application in the standardized format.
2 replies to this topic
#1
Posted 23 March 2011 - 07:38 PM
|
|
|
#2
Posted 27 March 2011 - 05:24 PM
Yes, you can do this. It works basically by creating a Class Library, that implements the functionality you wish for the plugin.
The trick is how you choose to implement it.
If you want the input filter to be explicitly configured, one great way to do this is to use a dependency injection runtime like Microsoft Unity.patterns & practices - Unity
A more cowboyish approach, would be to just reflectively load up your 'plugins'. (like literally scan a directory to dll files, and attempt to load them up as assemblies into an App Domain)
In any case, you're dealing with a situation where you would want to create an interface for your import plugin's to implement.
you want to end up with something like this.
so that you can say...
The whole thing can work really well if you do it right. But remember that the plugins will have a dependency to whatever you compile them against. There are situations where even though you might wish to patch one item, rebuilding one could cause another to need to be rebuilt.
The trick is how you choose to implement it.
If you want the input filter to be explicitly configured, one great way to do this is to use a dependency injection runtime like Microsoft Unity.patterns & practices - Unity
A more cowboyish approach, would be to just reflectively load up your 'plugins'. (like literally scan a directory to dll files, and attempt to load them up as assemblies into an App Domain)
In any case, you're dealing with a situation where you would want to create an interface for your import plugin's to implement.
you want to end up with something like this.
interface IImporter {
bool import(string source);
}
so that you can say...
IImporter dynamic_importer = get_import_plugin();
The whole thing can work really well if you do it right. But remember that the plugins will have a dependency to whatever you compile them against. There are situations where even though you might wish to patch one item, rebuilding one could cause another to need to be rebuilt.
#3
Posted 29 March 2011 - 01:52 AM
There is a more simple way : MEF for Managed Extensibility Framework.
Here is a link : MEF on CodePlex
Here is a link : MEF on CodePlex
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users


Sign In
Create Account


Back to top









