Plugin development

How RootSection plugins work

When a new WMFS instance starts up, the RootSelectManager seaches for .dll assamblys in %program folder%/plugins/.
It then loads all public classes found in the assamblys into memory.
Each plugin class has a special method that is then called and registers itself to the RootSelectManager.

Components of a RootSelection plugin

A RootSelection plugin is represented by a class, inheriting the WinMergeFS.Common.IRootSelectPlugin interface. So you need a reference to WinMergeFS-Common.dll.
The PluginRegister method then adds a RootSelectPluginDelegate of the plugin main function to the RootSelectManager plugin list, one for handling files, one for directorys.

PluginRegister method

The PluginRegister method needs the following parameters:

Profile profile: The current WMFS settingsprofile.
LoggerEventHandler logger: Delegate to provide logging to plugins. Syntax is logger(String message, LogLevel level)
ref Dictionary<string, RootSelectPluginDelegate> fileratinghandler: Dictionary to store method delegates on RootSelectManager. Use an unique plugin ID as string parameter. That is what users have to set in WMFS profiles.
ref Dictionary<string, RootSelectPluginDelegate> dirratinghandler: Same as above, just for directory methods.

Plugin main method

For the plugin main method to fit to RootSelectPluginDelegate it has to have the following parameters:

Profile profile: The current WMFS settingsprofile.
ref List<int> rootrating: Stores points for each root. The root with the most points is used to create new files and folders.
string filename: Filename of the file or folder that is to be created.

You can use one method for both, files and folder, or one for each.

Source Code

Download WMFS-RootSelect_TestPlugin.rar for source code.

Last edited Aug 23, 2009 at 7:44 PM by Duke, version 9


No comments yet.