コード例 #1
0
        /// <summary>
        /// Only for use by plugins during IPlugin.Install. Call Plugin.Install instead of this method, since plugins often must perform other initialization actions.
        /// Adds the specified plugin to AllPlugins, QuerystringPlugins, CachingSystems, ImageEncoders, and ImageBuilderExtensions, based
        /// on which interfaces the instance implements. For ICache and IEncoder, the plugin is inserted at the beginning of CachingSystems and ImageEncoders respectively.
        /// To reiterate, plugins may register event handlers and modify settings - thus you should use the plugin's method to uninstall them vs. using this method.
        /// Will not register a plugin that is already installed, unless it implements IMultiInstancePlugin.
        /// </summary>
        /// <param name="plugin"></param>
        public void add_plugin(IPlugin plugin)
        {
            if (!(plugin is IMultiInstancePlugin) && HasPlugin(plugin.GetType()))
            {
                AcceptIssue(new Issue("An instance of the specified plugin (" + plugin.GetType().ToString() + ") has already been registered.",
                                      "The plugin should implement IMultiInstancePlugin to support multiple instances.", IssueSeverity.Error));
                return;
            }

            AllPlugins.Add(plugin);
            if (plugin is IQuerystringPlugin)
            {
                QuerystringPlugins.Add(plugin as IQuerystringPlugin);
            }
            if (plugin is IFileExtensionPlugin)
            {
                FileExtensionPlugins.Add(plugin as IFileExtensionPlugin);
            }
            if (plugin is ICache)
            {
                CachingSystems.AddFirst(plugin as ICache);
            }
            if (plugin is IEncoder)
            {
                ImageEncoders.AddFirst(plugin as IEncoder);
            }
            if (plugin is BuilderExtension)
            {
                ImageBuilderExtensions.Add(plugin as BuilderExtension);
            }
            if (plugin is IVirtualImageProvider)
            {
                VirtualProviderPlugins.Add(plugin as IVirtualImageProvider);
            }
            if (plugin is ISettingsModifier)
            {
                SettingsModifierPlugins.Add(plugin as ISettingsModifier);
            }
            if (plugin is ICurrentConfigProvider)
            {
                ConfigProviders.Add(plugin as ICurrentConfigProvider);
            }
            if (plugin is ILogManager)
            {
                LogManager = plugin as ILogManager;
            }
            if (plugin is ILicensedPlugin || plugin is ILicenseProvider)
            {
                FireLicensePluginsChange();
            }
        }
コード例 #2
0
 /// <summary>
 /// For use only by plugins during .Uninstall.
 /// Removes the specified plugin from AllPlugins, QuerystringPlugins, CachingSystems, ImageEncoders, and ImageBuilderExtensions, based
 /// on which interfaces the instance implements.
 /// Plugins may register event handlers and modify settings - thus you should use the plugin's method to uninstall them vs. using this method.
 /// </summary>
 /// <param name="plugin"></param>
 public void remove_plugin(object plugin)
 {
     if (plugin is IPlugin)
     {
         AllPlugins.Remove(plugin as IPlugin);
     }
     if (plugin is IQuerystringPlugin)
     {
         QuerystringPlugins.Remove(plugin as IQuerystringPlugin);
     }
     if (plugin is IFileExtensionPlugin)
     {
         FileExtensionPlugins.Remove(plugin as IFileExtensionPlugin);
     }
     if (plugin is ICache)
     {
         CachingSystems.Remove(plugin as ICache);
     }
     if (plugin is IEncoder)
     {
         ImageEncoders.Remove(plugin as IEncoder);
     }
     if (plugin is BuilderExtension)
     {
         ImageBuilderExtensions.Remove(plugin as BuilderExtension);
     }
     if (plugin is IVirtualImageProvider)
     {
         VirtualProviderPlugins.Remove(plugin as IVirtualImageProvider);
     }
     if (plugin is ISettingsModifier)
     {
         SettingsModifierPlugins.Remove(plugin as ISettingsModifier);
     }
     if (plugin is ICurrentConfigProvider)
     {
         ConfigProviders.Remove(plugin as ICurrentConfigProvider);
     }
     if (plugin is ILogManager && LogManager == plugin)
     {
         LogManager = null;
     }
     if (plugin is ILicensedPlugin || plugin is ILicenseProvider)
     {
         FireLicensePluginsChange();
     }
 }
コード例 #3
0
        /// <summary>
        /// Removes all plugins, of every kind. Logs any errors encountered. (Not all plugins support uninstallation)
        /// </summary>
        public void RemoveAll()
        {
            //Follow uninstall protocol
            foreach (IPlugin p in AllPlugins)
            {
                if (!p.Uninstall(c))
                {
                    this.AcceptIssue(new Issue("Uninstall of " + p.ToString() + " reported failure.", IssueSeverity.Error));
                }
            }

            IList[] collections = new IList[] { AllPlugins.GetCollection(), QuerystringPlugins.GetCollection(), FileExtensionPlugins.GetCollection()
                                                , CachingSystems.GetCollection(), ImageEncoders.GetCollection(), ImageBuilderExtensions.GetCollection() };
            //Then check all collections, logging an issue if they aren't empty.
            foreach (IList coll in collections)
            {
                if (coll.Count > 0)
                {
                    string items = "";
                    foreach (object item in coll)
                    {
                        items += item.ToString() + ", ";
                    }

                    this.AcceptIssue(new Issue("Collection " + coll.ToString() + " was not empty after RemoveAllPlugins() executed!",
                                               "Remaining items: " + items, IssueSeverity.Error));
                }
            }
        }