コード例 #1
0
        /// <summary>
        /// Pluginses the specified page.
        /// </summary>
        /// <param name="page">The page.</param>
        private void Plugins(Page page)
        {
            for (int i = 0; i < page.Containers.Count; i++)
            {
                for (int b = 0; b < page.Containers[i].Elements.Count; b++)
                {
                    XmlNode xmlElementNode = page.Containers[i].Elements[b].Node;
                    String  plugin         = CommonXml.GetNode(xmlElementNode, "plugin").InnerText;
                    String  action         = CommonXml.GetNode(xmlElementNode, "action").InnerText;
                    if (plugin != String.Empty & action != String.Empty)
                    {
                        String          pathTrail       = CommonXml.GetNode(xmlElementNode, "value").InnerText;
                        AvailablePlugin availablePlugin = Process.Plugins.AvailablePlugins.Find(plugin);
                        if (availablePlugin != null)
                        {
                            IPlugin2 plugin2 = availablePlugin.Instance as IPlugin2;
                            if (plugin2 != null)
                            {
                                IPlugin2 iPlugin = availablePlugin.Instance as IPlugin2;

                                iPlugin.Load(new ControlList(xmlElementNode), action, String.Empty, pathTrail);
                            }
                            else
                            {
                                IPlugin iPlugin = availablePlugin.Instance;

                                iPlugin.Load(new ControlList(xmlElementNode), action, pathTrail);
                            }
                        }
                    }
                }
            }
        }
コード例 #2
0
        public void PluginMenuClicked(string pluginName, string menuItem)
        {
            foreach (var mapWinPlugin in MapWinPlugins)
            {
                if ((string)mapWinPlugin.Metadata["PluginName"] == pluginName)
                {
                    if (mapWinPlugin.Value is IPlugin2)
                    {
                        IPlugin2 plugin = mapWinPlugin.Value as IPlugin2;

                        plugin.MenuButtonClicked(menuItem);
                    }
                }
            }
        }
コード例 #3
0
        public IEnumerable <AvailablePlugin> FindImplementations(string api)
        {
            List <AvailablePlugin> plugins = new List <AvailablePlugin>();

            foreach (AvailablePlugin plugin in List)
            {
                IPlugin2 instance = plugin.Instance as IPlugin2;
                if (instance != null && instance.Implements != null)
                {
                    List <string> implements = new List <string>(instance.Implements);
                    if (implements.Contains(api))
                    {
                        plugins.Add(plugin);
                    }
                }
            }

            return(plugins);
        }
コード例 #4
0
        /// <summary>
        /// Invokes the action on all plug-ins implementing the specified API.
        /// </summary>
        /// <param name="api">API</param>
        /// <param name="action">Action to invoke</param>
        /// <param name="args">Arguments, are passed on to the Plugins</param>
        /// <returns>An array of results from the Plugins (only non-null values are included)</returns>
        public object[] InvokeAll(string api, string action, params object[] args)
        {
            List <object> results = new List <object>();

            List <AvailablePlugin> plugins = AvailablePlugins.FindImplementations(api);

            foreach (AvailablePlugin plugin in plugins)
            {
                IPlugin2 invokablePlugin = plugin.Instance as IPlugin2;
                if (invokablePlugin == null)
                {
                    continue;
                }
                object result = invokablePlugin.Invoke(api, action, args);
                if (result != null)
                {
                    results.Add(result);
                }
            }

            return(results.ToArray());
        }