Beispiel #1
0
        public bool AddSourceFile(string sourceFile)
        {
            if (this.loadedSourceFiles.Contains(sourceFile))
            {
                return(false);
            }

            Node        node        = this.LookupEntryPoint("various") ?? base.RootNode;
            XmlDocument xmlDocument = new XmlDocument();

            try {
                xmlDocument.Load(sourceFile);
            } catch {
                bool result = false;
                return(result);
            }

            XmlNodeList extra_nodes = xmlDocument.SelectNodes("/monodoc/node");

            if (extra_nodes.Count > 0)
            {
                this.Populate(node, extra_nodes);
            }

            XmlNodeList sources = xmlDocument.SelectNodes("/monodoc/source");

            if (sources == null)
            {
                Console.Error.WriteLine("Error: No <source> section found in the {0} file", sourceFile);
                return(false);
            }

            loadedSourceFiles.Add(sourceFile);
            foreach (XmlNode xmlNode in sources)
            {
                XmlAttribute a = xmlNode.Attributes["provider"];
                if (a == null)
                {
                    Console.Error.WriteLine("Error: no provider in <source>");
                    continue;
                }
                string provider = a.InnerText;
                a = xmlNode.Attributes["basefile"];
                if (a == null)
                {
                    Console.Error.WriteLine("Error: no basefile in <source>");
                    continue;
                }
                string basefile = a.InnerText;
                a = xmlNode.Attributes["path"];
                if (a == null)
                {
                    Console.Error.WriteLine("Error: no path in <source>");
                    continue;
                }
                string     path         = a.InnerText;
                string     basefilepath = Path.Combine(Path.GetDirectoryName(sourceFile), basefile);
                HelpSource helpSource   = RootTree.GetHelpSource(provider, basefilepath);
                if (helpSource != null)
                {
                    helpSource.RootTree = this;
                    this.helpSources.Add(helpSource);
                    this.nameToHelpSource[path] = helpSource;
                    Node node2 = this.LookupEntryPoint(path);
                    if (node2 == null)
                    {
                        Console.Error.WriteLine("node `{0}' is not defined on the documentation map", path);
                        node2 = node;
                    }
                    foreach (Node current in helpSource.Tree.RootNode.ChildNodes)
                    {
                        node2.AddNode(current);
                    }
                    node2.Sort();
                }
            }
            return(true);
        }