Пример #1
0
        internal void RemoveAddinExtensions(string id)
        {
            try {
                // Registers this add-in as disabled, so from now on extension from this
                // add-in will be ignored
                RegisterRuntimeDisabledAddin(id);

                fireEvents = true;

                // This method removes all extension nodes added by the add-in
                // Get all nodes created by the addin
                ArrayList list = new ArrayList();
                tree.FindAddinNodes(id, list);

                // Remove each node and notify the change
                foreach (TreeNode node in list)
                {
                    if (node.ExtensionNode == null)
                    {
                        // It's an extension point. Just remove it, no notifications are needed
                        node.Remove();
                    }
                    else
                    {
                        node.ExtensionNode.OnAddinUnloaded();
                        node.Remove();
                    }
                }

                // Notify global extension point changes.
                // The event is called for all extensions, even for those not loaded. This is for coherence,
                // although that something that it doesn't make much sense to do (subcribing the ExtensionChanged
                // event without first getting the list of nodes that may change).
                Addin addin = AddinManager.Registry.GetAddin(id);
                if (addin != null)
                {
                    ArrayList paths = new ArrayList();
                    foreach (ModuleDescription mod in addin.Description.AllModules)
                    {
                        foreach (Extension ext in mod.Extensions)
                        {
                            if (!paths.Contains(ext.Path))
                            {
                                paths.Add(ext.Path);
                            }
                        }
                    }
                    foreach (string path in paths)
                    {
                        NotifyExtensionsChanged(new ExtensionEventArgs(path));
                    }
                }
            } finally {
                fireEvents = false;
            }
        }
        internal void RemoveAddinExtensions(string id)
        {
            try {
                // Registers this add-in as disabled, so from now on extension from this
                // add-in will be ignored
                RegisterRuntimeDisabledAddin(id);

                fireEvents = true;

                // This method removes all extension nodes added by the add-in
                // Get all nodes created by the addin
                ArrayList list = new ArrayList();
                tree.FindAddinNodes(id, list);

                // Remove each node and notify the change
                ArrayList paths = new ArrayList();
                foreach (TreeNode node in list)
                {
                    if (node.ExtensionNode == null)
                    {
                        // It's an extension point. Just remove it, no notifications are needed
                        node.Remove();
                    }
                    else
                    {
                        string path = node.Parent.GetPath();
                        if (!paths.Contains(path))
                        {
                            paths.Add(path);
                        }
                        node.ExtensionNode.OnAddinUnloaded();
                        node.Remove();
                    }
                }

                // Notify global extension point changes
                foreach (string path in paths)
                {
                    NotifyExtensionsChanged(new ExtensionEventArgs(path));
                }
            } finally {
                fireEvents = false;
            }
        }