Пример #1
0
        private void ParseClassHtml(TypeScriptContext tsc, string fullName, string desc, HtmlNode section)
        {
            var cl = tsc.FindType(fullName) as ClassDeclaration;

            if (cl == null)
            {
                var i  = fullName.LastIndexOf('.');
                var md = tsc.GetModule(fullName.Substring(0, i));

                cl = new ClassDeclaration()
                {
                    Name     = fullName.Substring(i + 1),
                    IsExport = true
                };

                md.Statements.Add(cl);
            }

            if (cl.Documentation == null && desc != null)
            {
                cl.Documentation = new Documentation()
                {
                    Summary = desc
                };
            }

            var e = new TypeEventArgs(cl);

            TypeParsing?.Invoke(this, e);

            var headers = section.SelectNodes("//h2|//h3[@class='symbol-name']");

            if (headers != null)
            {
                var t = H2.None;
                foreach (var h in headers)
                {
                    if (h.Name.Equals("h2", StringComparison.InvariantCultureIgnoreCase))
                    {
                        switch (h.InnerText.Trim().ToLowerInvariant())
                        {
                        case "constructor":
                            t = H2.Constructor;
                            break;

                        case "enumerations":
                        case "enumeration":
                            t = H2.Enum;
                            break;

                        case "properties":
                        case "property":
                            t = H2.Property;
                            break;

                        case "methods":
                        case "method":
                            t = H2.Method;
                            break;

                        case "namespaces":
                        case "namespace":
                            t = H2.Namespace;
                            break;

                        default:
                            t = H2.None;
                            Debugger.Break();
                            break;
                        }
                    }
                    else
                    {
                        var sn = h.InnerText.Trim();
                        switch (t)
                        {
                        case H2.Constructor:
                            ProcessConstructor(tsc, cl, h, sn);
                            break;

                        case H2.Property:
                            ProcessProperty(tsc, cl, h, sn);
                            break;

                        case H2.Method:
                            ProcessMethod(tsc, cl, h, sn);
                            break;

                        default:
                            break;
                        }
                    }
                }
            }
            TypeParsed?.Invoke(this, e);
        }