Exemple #1
0
        public Stream GetImage(string url)
        {
            if (url.StartsWith("source-id:", StringComparison.OrdinalIgnoreCase))
            {
                string text  = url.Substring(10);
                int    num   = text.IndexOf(":");
                string text2 = text.Substring(0, num);
                int    id    = 0;
                try {
                    id = int.Parse(text2);
                } catch {
                    Console.Error.WriteLine("Failed to parse source-id url: {0} `{1}'", url, text2);
                    return(null);
                }
                HelpSource helpSourceFromId = this.GetHelpSourceFromId(id);
                return(helpSourceFromId.GetImage(text.Substring(num + 1)));
            }
            Assembly assembly = Assembly.GetAssembly(typeof(RootTree));

            return(assembly.GetManifestResourceStream(url));
        }
Exemple #2
0
        public HelpSource GetHelpSourceAndIdForUrl(string url, out string internalId, out Node node)
        {
            node       = null;
            internalId = null;

            if (url.StartsWith("root:/", StringComparison.OrdinalIgnoreCase))
            {
                return(this.GetHelpSourceAndIdFromName(url.Substring("root:/".Length), out internalId, out node));
            }

            HelpSource helpSource = null;

            foreach (var hs in helpSources.Where(h => h.CanHandleUrl(url)))
            {
                if (!string.IsNullOrEmpty(internalId = hs.GetInternalIdForUrl(url, out node)))
                {
                    helpSource = hs;
                    break;
                }
            }

            return(helpSource);
        }
Exemple #3
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.Nodes)
                    {
                        node2.AddNode(current);
                    }
                    node2.Sort();
                }
            }
            return(true);
        }
Exemple #4
0
 //
 // Called at shutdown time after the tree has been populated to perform
 // any fixups or final tasks.
 //
 public abstract void CloseTree(HelpSource hs, Tree tree);
Exemple #5
0
 public Tree(HelpSource hs, Node parent, string caption, string element)
 {
     HelpSource = hs;
     rootNode   = parent == null ? new Node(this, caption, element) : new Node(parent, caption, element);
 }
Exemple #6
0
 /// <summary>
 ///    Tree creation and merged tree constructor
 /// </summary>
 public Tree(HelpSource hs, string caption, string url) : this(hs, null, caption, url)
 {
 }