internal void removeMergedDocument(HTMLDocument input, HTMLDocument remainingDocument)
 {
     EducationCollection.Remove(input);
     EducationObjects.Remove(HTMLDocument.URLForDictionary(input.URL));
     EducationObjects.Remove(HTMLDocument.URLForDictionary(remainingDocument.URL));
     EducationObjects.Add(HTMLDocument.URLForDictionary(input.URL), remainingDocument);
     EducationObjectsByDatabaseID.Remove(input.DocID);
     obsoleteDocuments.Add(input);
 }
        public void loadDocument(OleDbDataReader reader)
        {
            string bundleName = reader.GetString((int)EducationDatabase.MetadataColumns.Bundle);

            foreach (XElement bundleSpec in ProviderSpecification.DescendantNodes().Where(n => n.NodeType == System.Xml.XmlNodeType.Element))
            {
                if (bundleSpec.Name == "Bundle" && bundleSpec.Attribute("name") != null && bundleSpec.Attribute("name").Value == bundleName)
                {
                    HTMLDocument loadDoc = new HTMLDocument(this, bundleSpec.Elements("Document").First(), reader);
                    EducationDatabase.Self().EducationObjects.Add(HTMLDocument.URLForDictionary(loadDoc.URL), loadDoc);
                    EducationDatabase.Self().EducationCollection.Add(loadDoc);
                }
            }
        }
        private HTMLDocument LoadDocumentInternal(XElement node, Uri link, string title)
        {
            HTMLDocument thisPage;

            if (!EducationDatabase.Self().EducationObjects.ContainsKey(HTMLDocument.URLForDictionary(link)))
            {
                thisPage = new HTMLDocument(this, node, link);
                // Postfix the content provider tag to the document title
                thisPage.Title = title + TitlePostfix;

                if (currentLoadDepth == LoadDepth.OneDocument)
                {
                    if (loadCount == 0)
                    {
                        loadCount++;
                        requestRetrieveAndParse(thisPage);
                    }
                }
                else if (currentLoadDepth == LoadDepth.Full)
                {
                    loadCount++;
                    requestRetrieveAndParse(thisPage);
                }

                EducationDatabase.Self().registerNewDocument(thisPage, HTMLDocument.URLForDictionary(link));
            }
            else
            {
                thisPage = (HTMLDocument)EducationDatabase.Self().EducationObjects[HTMLDocument.URLForDictionary(link)];

                // Update the status to show it was found in the index
                thisPage.foundInWebIndex();

                // Update the link in case it has subtly changed eg. http to https, case of URL etc.
                if (thisPage.URL != link)
                {
                    EducationDatabase.Self().updateDocumentURL(thisPage, HTMLDocument.URLForDictionary(thisPage.URL), HTMLDocument.URLForDictionary(link));
                    thisPage.URL = link;
                }

                if (currentLoadDepth == LoadDepth.Full)
                {
                    requestRetrieveAndParse(thisPage);
                }
            }

            MainWindow.thisWindow.IndexProgress.Value++;

            return(thisPage);
        }