private void UnloadPlugin(string Name) { if (!plugins.ContainsKey(Name)) { Logger.Error("Cannot removed plugin with name " + Name); throw new ArgumentException("The plugin with name " + Name + " cannot be removed because it does not exist.", "Name"); } SC.Interfaces.IScStandalonePluginBase plugin = plugins[Name]; plugins.Remove(Name); try { plugin.Destroy(); } catch (Exception e) { Logger.Error("An unknown error occurred during destruction of plugin " + Name, e); throw new SC.Interfaces.SCException("Unexpected error occurred during unload of plugin", e); } finally { try { plugin.Stop(); } catch (Exception e) { Logger.Error("An unknown error occurred while stopping plugin " + Name, e); throw new SC.Interfaces.SCException("Unexpected error occurred during unload of plugin", e); } SC.Security.SecurityManager.Instance.UnAuthenticate(); } }
private void LoadPlugin(string Name) { if (plugins.ContainsKey(Name)) { throw new SC.Interfaces.SCException("Plugin " + Name + " is already present."); } // Load plugin SC.Interfaces.IScStandalonePluginBase plugin = null; try { plugin = SC.PluginLoader.PluginLoader.Instance.LoadStandalonePlugin(Name); } catch (NotSupportedException e) { Logger.Error("Plugin " + Name + " does not support standalone operation.", e); throw new SC.Interfaces.SCException(e); } catch (Exception e) { Logger.Error("Unexpected exception during creation of plugin " + Name, e); throw new SC.Interfaces.SCException(e); } if (plugin == null) { Logger.Error("No plugin found with name " + Name); throw new ArgumentException("Plugin with name " + Name + " does not exist.", "Name"); } // Make sure it's licensed try { plugin.AssertLicense(); } catch (SC.Interfaces.LicenseException e) { Logger.Error("Plugin is not licensed.", e); throw; } // Initialize and start it. try { plugin.SetProvider(new StandaloneProvider(Name, this)); plugin.Start(); plugins[Name] = plugin; } catch (SC.Interfaces.LicenseException lic) { Logger.Error("No license available for plugin.", lic); throw; } catch (Exception e) { Logger.Error("Could not start plugin.", e); throw new SC.Interfaces.SCException("Could not start plugin", e); } }