Exemplo n.º 1
0
 static ManagedType()
 {
     dummy_system_package = new JavaPackage(null)
     {
         Name = "System"
     };
     system_object = new ManagedType(dummy_system_package)
     {
         Name = "Object"
     };
     system_exception = new ManagedType(dummy_system_package)
     {
         Name = "Exception"
     };
     dummy_system_package.AddType(system_object);
     dummy_system_package.AddType(system_exception);
     dummy_system_io_package = new JavaPackage(null)
     {
         Name = "System.IO"
     };
     system_io_stream = new ManagedType(dummy_system_io_package)
     {
         Name = "Stream"
     };
     dummy_system_io_package.AddType(system_io_stream);
     dummy_system_xml_package = new JavaPackage(null)
     {
         Name = "System.Xml"
     };
     system_xml_xmlreader = new ManagedType(dummy_system_xml_package)
     {
         Name = "XmlReader"
     };
     dummy_system_io_package.AddType(system_xml_xmlreader);
 }
        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();
            }
        }