public void Unregister()
        {
            foreach (PluginParentItem plugin in this.plugins)
            {
                if (string.IsNullOrEmpty(plugin.MatchingName))
                {
                    continue;
                }

                using (Help2RegisterClass register = new Help2RegisterClass())
                {
                    foreach (PluginChildItem child in plugin)
                    {
                        if (string.IsNullOrEmpty(child.MatchingName))
                        {
                            continue;
                        }

                        OnRegisterOrRemovePlugin(new PluginRegisterEventArgs(plugin.MatchingName, child.MatchingName, false));
                        register.RemovePlugin(plugin.MatchingName, child.MatchingName);
                    }

                    if (plugin.Merge)
                    {
                        OnNamespaceMerge(new MergeNamespaceEventArgs(plugin.MatchingName));
                        MergeNamespace.CallMerge(plugin.MatchingName);
                    }
                }
            }
        }
        public void Unregister()
        {
            foreach (NamespaceItemClass helpNamespace in helpNamespaces)
            {
                if (string.IsNullOrEmpty(helpNamespace.Name))
                {
                    continue;
                }

                using (Help2RegisterClass register = new Help2RegisterClass())
                {
                    // remove this Help 2.0 namespace, if it is a plug-in
                    foreach (string connectedNamespace in helpNamespace.ConnectedNamespaces)
                    {
                        OnRegisterOrRemovePlugin(new PluginRegisterEventArgs(connectedNamespace, helpNamespace.Name, false));
                        register.RemovePlugin(connectedNamespace, helpNamespace.Name);

                        OnNamespaceMerge(new MergeNamespaceEventArgs(connectedNamespace));
                        MergeNamespace.CallMerge(connectedNamespace);
                    }

                    // remove this namespace's child plug-ins
                    foreach (PluginChildItem plugin in helpNamespace.Plugins)
                    {
                        OnLogProgress(new LoggingEventArgs(plugin.ToString()));
                        OnRegisterOrRemovePlugin(new PluginRegisterEventArgs(helpNamespace.Name, plugin.MatchingName, false));
                        register.RemovePlugin(helpNamespace.Name, plugin.MatchingName);
                    }

                    // remove this namespace's filters
                    foreach (FilterItemClass filter in helpNamespace.Filters)
                    {
                        OnLogProgress(new LoggingEventArgs(filter.ToString()));
                        OnRegisterOrRemoveFilter(new CommonRegisterEventArgs(filter.Name, false));
                        register.RemoveFilter(helpNamespace.Name, filter.Name);
                    }

                    // remove this namespace's documents
                    foreach (DocumentItemClass document in helpNamespace.Documents)
                    {
                        OnLogProgress(new LoggingEventArgs(document.ToString()));
                        OnRegisterOrRemoveHelpDocument(new CommonRegisterEventArgs(document.Id, false));
                        register.RemoveHelpFile(helpNamespace.Name, document.Id, document.LanguageId);
                    }

                    // remove this namespace, ...
                    if (helpNamespace.Remove)
                    {
                        OnRegisterOrRemoveNamespace(new CommonRegisterEventArgs(helpNamespace.Name, false));
                        register.RemoveNamespace(helpNamespace.Name);
                    }
                    // ... or just (re)merge it
                    else
                    {
                        OnNamespaceMerge(new MergeNamespaceEventArgs(helpNamespace.Name));
                        MergeNamespace.CallMerge(helpNamespace.Name);
                    }
                }
            }
        }
        public void Register()
        {
            foreach (NamespaceItemClass helpNamespace in helpNamespaces)
            {
                if (string.IsNullOrEmpty(helpNamespace.Name) ||
                    string.IsNullOrEmpty(helpNamespace.CollectionLevelFile) ||
                    !File.Exists(helpNamespace.CollectionLevelFile))
                {
                    continue;
                }

                using (Help2RegisterClass register = new Help2RegisterClass())
                {
                    // force Help 2.0 namespace creation
                    if (helpNamespace.ForceCreation)
                    {
                        OnLogProgress(new LoggingEventArgs(helpNamespace.ToString()));
                        OnRegisterOrRemoveNamespace(new CommonRegisterEventArgs(helpNamespace.Name, true));
                        register.RegisterNamespace(helpNamespace.Name,
                                                   helpNamespace.CollectionLevelFile,
                                                   helpNamespace.Description);
                    }

                    // register Help 2.0 documents
                    foreach (DocumentItemClass document in helpNamespace.Documents)
                    {
                        if (string.IsNullOrEmpty(document.Id) ||
                            string.IsNullOrEmpty(document.Hxs) ||
                            !File.Exists(document.Hxs))
                        {
                            continue;
                        }

                        OnLogProgress(new LoggingEventArgs(document.ToString()));
                        OnRegisterOrRemoveHelpDocument(new CommonRegisterEventArgs(document.Id, true));
                        register.RegisterHelpFile(helpNamespace.Name,
                                                  document.Id,
                                                  document.LanguageId,
                                                  document.Hxs,
                                                  document.Hxi,
                                                  document.Hxq,
                                                  document.Hxr,
                                                  document.HxsMediaId,
                                                  document.HxqMediaId,
                                                  document.HxrMediaId,
                                                  document.SampleMediaId);
                    }

                    // register Help 2.0 filters
                    foreach (FilterItemClass filter in helpNamespace.Filters)
                    {
                        if (string.IsNullOrEmpty(filter.Name))
                        {
                            continue;
                        }

                        OnLogProgress(new LoggingEventArgs(filter.ToString()));
                        OnRegisterOrRemoveFilter(new CommonRegisterEventArgs(filter.Name, true));
                        register.RegisterFilter(helpNamespace.Name, filter.Name, filter.Query);
                    }

                    // register Help 2.0 child plug-ins
                    foreach (PluginChildItem plugin in helpNamespace.Plugins)
                    {
                        if (string.IsNullOrEmpty(plugin.MatchingName))
                        {
                            continue;
                        }

                        OnLogProgress(new LoggingEventArgs(plugin.ToString()));
                        OnRegisterOrRemovePlugin(new PluginRegisterEventArgs(helpNamespace.Name, plugin.MatchingName, true));
                        register.RegisterPlugin(helpNamespace.Name, plugin.MatchingName);

                        if (string.Compare(plugin.Name, plugin.MatchingName) != 0)
                        {
                            this.PatchXmlNode(helpNamespace.Name, plugin.Name, plugin.MatchingName);
                        }
                    }

                    // merge Help 2.0 namespace
                    if (helpNamespace.Merge)
                    {
                        OnLogProgress(new LoggingEventArgs(string.Format(CultureInfo.InvariantCulture, "[merging {0}]", helpNamespace.Name)));
                        OnNamespaceMerge(new MergeNamespaceEventArgs(helpNamespace.Name));
                        MergeNamespace.CallMerge(helpNamespace.Name);

                        foreach (string connectedNamespace in helpNamespace.ConnectedNamespaces)
                        {
                            OnLogProgress(new LoggingEventArgs(string.Format(CultureInfo.InvariantCulture, "[merging {0}]", connectedNamespace)));
                            OnNamespaceMerge(new MergeNamespaceEventArgs(connectedNamespace));
                            MergeNamespace.CallMerge(connectedNamespace);
                        }
                    }
                }
            }
        }