public static void Load(this JavaPackage package, XmlReader reader, bool isReferenceOnly)
        {
            reader.MoveToContent();
            package.Name    = XmlUtil.GetRequiredAttribute(reader, "name");
            package.JniName = reader.GetAttribute("jni-name");
            if (reader.MoveToFirstAttribute())
            {
                if (reader.LocalName != "name")
                {
                    throw XmlUtil.UnexpectedAttribute(reader, "package");
                }
            }
            reader.MoveToElement();
            if (reader.IsEmptyElement)
            {
                reader.Read();
            }
            else
            {
                reader.Read();
                do
                {
                    reader.MoveToContent();
                    if (reader.NodeType == XmlNodeType.EndElement)
                    {
                        break;                         // </package>
                    }
                    if (reader.NodeType != XmlNodeType.Element)
                    {
                        throw XmlUtil.UnexpectedElementOrContent("package", reader, "class", "interface");
                    }
                    if (reader.LocalName == "class")
                    {
                        var kls = new JavaClass(package)
                        {
                            IsReferenceOnly = isReferenceOnly
                        };
                        kls.Load(reader);
                        package.AddType(kls);
                    }
                    else if (reader.LocalName == "interface")
                    {
                        var iface = new JavaInterface(package)
                        {
                            IsReferenceOnly = isReferenceOnly
                        };
                        iface.Load(reader);
                        package.AddType(iface);
                    }
                    else
                    {
                        throw XmlUtil.UnexpectedElementOrContent("package", reader, "class", "interface");
                    }
                } while (true);

                XmlUtil.VerifyEndElement(reader, "package");
                reader.Read();
            }
        }
Exemple #2
0
 internal static void CheckExtraneousAttributes(string elementName, XmlReader reader, params string [] expected)
 {
     if (reader.MoveToFirstAttribute())
     {
         do
         {
             if (!expected.Contains(reader.LocalName))
             {
                 throw XmlUtil.UnexpectedAttribute(reader, elementName, expected);
             }
         } while (reader.MoveToNextAttribute());
     }
     reader.MoveToElement();
 }