Microsoft.Html.Core.Tree.HtmlTree.Accept C# (CSharp) Method

Accept() public method

public Accept ( Func visitor, object param ) : bool
visitor Func
param object
return bool
        public bool Accept(Func<ElementNode, object, bool> visitor, object param) {
            return RootNode.Accept(visitor, param);
        }
        #endregion

Same methods

HtmlTree::Accept ( IHtmlTreeVisitor visitor, object param ) : bool

Usage Example

Beispiel #1
0
        internal IReadOnlyList<INamedItemInfo> LoadFunctionInfoFromPackageHelpIndex() {
            List<INamedItemInfo> functions = new List<INamedItemInfo>();
            string content = null;

            try {
                string htmlFile = Path.Combine(this.InstallPath, this.Name, "html", "00index.html");
                if (File.Exists(htmlFile)) {
                    using (StreamReader sr = new StreamReader(htmlFile, Encoding.UTF8)) {
                        content = sr.ReadToEnd();
                    }
                }
            } catch (IOException) { }

            if (!string.IsNullOrEmpty(content)) {
                HtmlTree tree = new HtmlTree(new Microsoft.Web.Core.Text.TextStream(content));
                tree.Build();

                FunctionSearch functionSearch = new FunctionSearch(functions);
                tree.Accept(functionSearch, null);
            }

            Dictionary<string, INamedItemInfo> functionIndex = new Dictionary<string, INamedItemInfo>();
            foreach (INamedItemInfo ni in functions) {
                functionIndex[ni.Name] = ni;
            }

            IReadOnlyDictionary<string, string> mappedNames = GetMappedNames();
            foreach (string mappedName in mappedNames.Keys) {
                INamedItemInfo ni;
                string actualName = mappedNames[mappedName];
                if (functionIndex.TryGetValue(actualName, out ni)) {
                    INamedItemInfo niAlias = new NamedItemInfo() {
                        Name = mappedName,
                        Description = ni.Description,
                        ItemType = ni.ItemType
                    };
                    functions.Add(niAlias);
                }
            }

            return functions;
        }