Ejemplo n.º 1
0
        List <GenBase> ParsePackage(XElement ns, Predicate <XElement> p)
        {
            List <GenBase> result = new List <GenBase> ();
            Dictionary <string, GenBase> nested  = new Dictionary <string, GenBase> ();
            Dictionary <string, GenBase> by_name = new Dictionary <string, GenBase> ();

            foreach (var elem in ns.Elements())
            {
                string  name = elem.XGetAttribute("name");
                GenBase gen  = null;
                switch (elem.Name.LocalName)
                {
                case "class":
                    if (elem.XGetAttribute("obfuscated") == "true")
                    {
                        continue;
                    }
                    gen = XmlApiImporter.CreateClass(ns, elem);
                    break;

                case "interface":
                    if (elem.XGetAttribute("obfuscated") == "true")
                    {
                        continue;
                    }
                    gen = XmlApiImporter.CreateInterface(ns, elem);
                    break;

                default:
                    Report.Warning(0, Report.WarningParser + 3, "Unexpected node in package element: {0}.", elem.Name);
                    break;
                }

                if (gen == null)
                {
                    continue;
                }
                int idx = name.IndexOf('<');
                if (idx > 0)
                {
                    name = name.Substring(0, idx);
                }
                by_name [name] = gen;
                if (name.IndexOf('.') > 0)
                {
                    nested [name] = gen;
                }
                else
                {
                    result.Add(gen);
                }
            }

            foreach (string name in nested.Keys)
            {
                string top_ancestor = name.Substring(0, name.IndexOf('.'));
                if (by_name.ContainsKey(top_ancestor))
                {
                    by_name [top_ancestor].AddNestedType(nested [name]);
                }
                else
                {
                    Report.Warning(0, Report.WarningParser + 4, "top ancestor {0} not found for nested type {1}.", top_ancestor, nested [name].FullName);
                    nested [name].Invalidate();
                }
            }
            return(result);
        }