示例#1
0
        private static ConfigPackInformation ReadPackInformation(ConfigPack selected)
        {
            WebClient   wc          = new WebClient();
            string      fullXmlText = wc.DownloadString(CONFIGDIR + selected.URL + "pge_cpack.xml");
            XmlDocument doc         = new XmlDocument();

            doc.LoadXml(fullXmlText);

            ConfigPackInformation cpi = new ConfigPackInformation();


            foreach (XmlNode node in doc.DocumentElement.ChildNodes)
            {
                if (cpi.PackName == null)
                {
                    cpi.PackName = node.ParentNode.Attributes["name"].Value;
                }
                switch (node.Name)
                {
                case ("head"):
                    cpi = IterateThroughHead(node, cpi);
                    break;

                case ("files"):
                    if (node.HasChildNodes)
                    {
                        foreach (XmlNode fileNode in node.ChildNodes)
                        {
                            if (fileNode.Name == "file")
                            {
                                FilesStruct temp = new FilesStruct();
                                //temp.Platform = (fileNode.Attributes["platform"].Value);
                                temp.Folder = (fileNode.Attributes["folder"].Value == null) ? "" : fileNode.Attributes["folder"].Value;
                                temp.URL    = fileNode.InnerText;

                                if (temp.URL != null && temp.Folder != null)
                                {
                                    cpi.FilesParts.Add(temp);
                                }
                            }
                        }
                    }
                    break;
                }
            }
            if (cpi.SplashURL != null && cpi.SplashURL != "")
            {
                cpi.SplashURL = CONFIGDIR + selected.URL + cpi.SplashURL;
            }
            if (cpi.IconURL != null && cpi.IconURL != "")
            {
                cpi.IconURL = CONFIGDIR + selected.URL + cpi.IconURL;
            }
            return(cpi);
        }
示例#2
0
        private static ConfigPackInformation TryReadPackInformation(ConfigPack selected)
        {
            XmlTextReader rreader = new XmlTextReader(CONFIGDIR + selected.URL + "pge_cpack.xml");

            string fullXmlText = "";
            while (rreader.Read())
                fullXmlText = rreader.ReadOuterXml();
            string ffullXmlText = fullXmlText.Trim(new char[]{ '\r', '\n', '\t', ' '});

            var reader = XmlReader.Create(new StringReader(ffullXmlText.Trim()));

            ConfigPackInformation PackInformation = new ConfigPackInformation();

            while (reader.Read())
            {
                switch (reader.NodeType)
                {
                    case XmlNodeType.Element:

                        if (reader.Name == "config")
                            PackInformation.PackName = reader.GetAttribute("name");
                        if (reader.Name == "description")
                            PackInformation.Description = reader.Value;
                        if (reader.Name == "icon")
                            PackInformation.IconURL = CONFIGDIR + selected.URL + "/" + reader.GetAttribute("img");
                        if (reader.Name == "splash")
                            PackInformation.SplashURL = CONFIGDIR + selected.URL + "/" + reader.GetAttribute("img");
                        if (reader.Name == "smbx64")
                            PackInformation.IsSMBX64 = (reader.GetAttribute("true") == "1") ? true : false;
                        if (reader.Name == "license")
                            reader.MoveToContent(); PackInformation.License = reader.Value;
                        if (reader.Name == "part")
                        {
                            string key = reader.GetAttribute("name");
                            List<AuthorStruct> values = new List<AuthorStruct>();
                            if (reader.ReadToDescendant("author"))
                            {
                                do
                                {
                                    if (reader.Name == "author")
                                    {
                                        AuthorStruct auth = new AuthorStruct();

                                        if (reader.GetAttribute("email") != null)
                                            auth.Email = reader.GetAttribute("email");
                                        if (reader.GetAttribute("url") != null)
                                            auth.Website = reader.GetAttribute("url");
                                        if (reader.GetAttribute("comment") != null)
                                            auth.Comment = reader.GetAttribute("comment");
                                        reader.MoveToContent(); auth.Author = reader.Value;

                                        values.Add(auth);
                                    }
                                }
                                while(reader.ReadToNextSibling("author"));
                            }

                            PackInformation.CreditsParts.Add(new KeyValuePair<string, AuthorStruct[]>(key, values.ToArray()));
                        }
                        if (reader.Name == "files")
                        {
                            List<FilesStruct> files = new List<FilesStruct>();
                            if (reader.ReadToDescendant("file"))
                            {
                                FilesStruct fs = new FilesStruct();
                                if (reader.GetAttribute("folder") != null)
                                    fs.Folder = reader.GetAttribute("folder");
                                reader.MoveToContent(); fs.URL = reader.Value;
                            }
                        }
                        break;

                }
            }
            return PackInformation;
        }
示例#3
0
        private static ConfigPackInformation ReadPackInformation(ConfigPack selected)
        {
            WebClient wc = new WebClient();
            string fullXmlText = wc.DownloadString(CONFIGDIR + selected.URL + "pge_cpack.xml");
            XmlDocument doc = new XmlDocument();
            doc.LoadXml(fullXmlText);

            ConfigPackInformation cpi = new ConfigPackInformation();

            foreach (XmlNode node in doc.DocumentElement.ChildNodes)
            {
                if(cpi.PackName == null)
                    cpi.PackName = node.ParentNode.Attributes["name"].Value;
                switch (node.Name)
                {
                    case("head"):
                        cpi = IterateThroughHead(node, cpi);
                        break;
                    case("files"):
                        if (node.HasChildNodes)
                        {
                            foreach (XmlNode fileNode in node.ChildNodes)
                            {
                                if (fileNode.Name == "file")
                                {
                                    FilesStruct temp = new FilesStruct();
                                    //temp.Platform = (fileNode.Attributes["platform"].Value);
                                    temp.Folder = (fileNode.Attributes["folder"].Value == null) ? "" : fileNode.Attributes["folder"].Value;
                                    temp.URL = fileNode.InnerText;

                                    if (temp.URL != null && temp.Folder != null)
                                        cpi.FilesParts.Add(temp);
                                }
                            }
                        }
                        break;
                }
            }
            if (cpi.SplashURL != null && cpi.SplashURL != "")
                cpi.SplashURL = CONFIGDIR + selected.URL + cpi.SplashURL;
            if (cpi.IconURL != null && cpi.IconURL != "")
                cpi.IconURL = CONFIGDIR + selected.URL + cpi.IconURL;
            return cpi;
        }
示例#4
0
        private static ConfigPackInformation TryReadPackInformation(ConfigPack selected)
        {
            XmlTextReader rreader = new XmlTextReader(CONFIGDIR + selected.URL + "pge_cpack.xml");

            string fullXmlText = "";

            while (rreader.Read())
            {
                fullXmlText = rreader.ReadOuterXml();
            }
            string ffullXmlText = fullXmlText.Trim(new char[] { '\r', '\n', '\t', ' ' });


            var reader = XmlReader.Create(new StringReader(ffullXmlText.Trim()));

            ConfigPackInformation PackInformation = new ConfigPackInformation();

            while (reader.Read())
            {
                switch (reader.NodeType)
                {
                case XmlNodeType.Element:

                    if (reader.Name == "config")
                    {
                        PackInformation.PackName = reader.GetAttribute("name");
                    }
                    if (reader.Name == "description")
                    {
                        PackInformation.Description = reader.Value;
                    }
                    if (reader.Name == "icon")
                    {
                        PackInformation.IconURL = CONFIGDIR + selected.URL + "/" + reader.GetAttribute("img");
                    }
                    if (reader.Name == "splash")
                    {
                        PackInformation.SplashURL = CONFIGDIR + selected.URL + "/" + reader.GetAttribute("img");
                    }
                    if (reader.Name == "smbx64")
                    {
                        PackInformation.IsSMBX64 = (reader.GetAttribute("true") == "1") ? true : false;
                    }
                    if (reader.Name == "license")
                    {
                        reader.MoveToContent();
                    }
                    PackInformation.License = reader.Value;
                    if (reader.Name == "part")
                    {
                        string key = reader.GetAttribute("name");
                        List <AuthorStruct> values = new List <AuthorStruct>();
                        if (reader.ReadToDescendant("author"))
                        {
                            do
                            {
                                if (reader.Name == "author")
                                {
                                    AuthorStruct auth = new AuthorStruct();

                                    if (reader.GetAttribute("email") != null)
                                    {
                                        auth.Email = reader.GetAttribute("email");
                                    }
                                    if (reader.GetAttribute("url") != null)
                                    {
                                        auth.Website = reader.GetAttribute("url");
                                    }
                                    if (reader.GetAttribute("comment") != null)
                                    {
                                        auth.Comment = reader.GetAttribute("comment");
                                    }
                                    reader.MoveToContent(); auth.Author = reader.Value;

                                    values.Add(auth);
                                }
                            }while(reader.ReadToNextSibling("author"));
                        }


                        PackInformation.CreditsParts.Add(new KeyValuePair <string, AuthorStruct[]>(key, values.ToArray()));
                    }
                    if (reader.Name == "files")
                    {
                        List <FilesStruct> files = new List <FilesStruct>();
                        if (reader.ReadToDescendant("file"))
                        {
                            FilesStruct fs = new FilesStruct();
                            if (reader.GetAttribute("folder") != null)
                            {
                                fs.Folder = reader.GetAttribute("folder");
                            }
                            reader.MoveToContent(); fs.URL = reader.Value;
                        }
                    }
                    break;
                }
            }
            return(PackInformation);
        }