/// <summary> /// Registers a <see cref="PluginBase"/> with this instance of <see cref="PluginController"/>. /// </summary> /// <param name="plugin">The Plugin to register.</param> public void Register(PluginBase plugin) { if(!IsPluginRegistered(plugin)) { plugins.Add(plugin); plugin.Host = this; foreach(ILogger logger in loggers) { if(logger!=null) { plugin.AttachLog(logger); } } ((IPlugin)plugin).StateChanged+=new EventHandler(PluginController_StateChanged); } else { throw new ArgumentException("This Plugin is already loaded and registered."); } }
/// <summary> /// Checks whether a <see cref="PluginBase">Plugin</see> is already registered with /// the controller. /// </summary> /// <param name="plugin">The plugin to check</param> /// <returns>True if the Plugin is already registered with the controller, false otherwise.</returns> private bool IsPluginRegistered(PluginBase plugin) { System.Type pt = plugin.GetType(); foreach(PluginBase loadedPlugin in plugins) { if(pt == loadedPlugin.GetType()) { return true; } } return false; }
/// <summary> /// Manages reporting permissions for plugins. /// </summary> /// <param name="plugin">The plugin that wishes to report an event.</param> /// <returns>True if the Plugin is permitted to report, otherwise false.</returns> public bool PermitReport(PluginBase plugin) { // TODO: Add PluginController.PermitReport implementation return true; }