I'm trying to replace the default pdf generation routines with my own (to make use of user-definable templates), I'm attempting to do this as plugin.
It works great except for one thing, it always uses my routines even when i "uninstall" the plugin....
I would like to be able to switch this plugin on or off depending on it's "installed" status, any help anyone could give would be very much appreciated.
I presume that you override the default PdfService with your one in the plugin using IDependencyRegistrar. The issue is that IDependencyRegistrar.Register is always invoked no matter whether a plugin is installed or not. That's why you have to add a validation to your Register method whether it's installed. Something like
//is plugin installed? var pluginDescriptor = _pluginFinder.GetPluginDescriptorBySystemName("YourSystemNameHere"); if (pluginDescriptor == null || !pluginDescriptor.Installed) return;
I finally find a solution to both find the IPluginFinder instance and to check if my plugin is already installed.
var pluginFinderTypes = typeFinder.FindClassesOfType<IPluginFinder>();
bool isInstalled = false;
foreach (var pluginFinderType in pluginFinderTypes) { var pluginFinder = Activator.CreateInstance(pluginFinderType) as IPluginFinder; var pluginDescriptor = pluginFinder.GetPluginDescriptorBySystemName("Misc.PDFReports");