Esempio n. 1
0
        private static ConfigPackInformation IterateThroughHead(XmlNode node, ConfigPackInformation cpi)
        {
            if (node.HasChildNodes)
            {
                foreach (XmlNode child in node.ChildNodes)
                {
                    switch (child.Name)
                    {
                        case("config"):
                            cpi.PackName = child.Attributes["name"].Value;
                            break;
                        case ("description"):
                            cpi.Description = child.InnerText;
                            break;
                        case("icon"):
                            cpi.IconURL = child.Attributes["img"].Value;
                            break;
                        case("splash"):
                            cpi.SplashURL = child.Attributes["img"].Value;;
                            break;
                        case("smbx64"):
                            if (child.Attributes["true"] != null)
                                cpi.IsSMBX64 = (child.Attributes["true"].Value == "1") ? true : false;
                            break;
                        case("license"):
                            cpi.License = child.InnerText;
                            break;
                        case("credits"):
                            if (child.HasChildNodes)
                            {
                                foreach (XmlNode partNode in child.ChildNodes)
                                {
                                    if (partNode.Name == "part")
                                    {
                                        string key = "";
                                        List<AuthorStruct> values = new List<AuthorStruct>();

                                        //XmlNode partNode = node.ChildNodes;
                                        key = (partNode.Attributes["name"].Value == null) ? "" : partNode.Attributes["name"].Value;
                                        if (partNode.HasChildNodes)
                                        {
                                            foreach (XmlNode childAuthor in partNode.ChildNodes)
                                            {
                                                if (childAuthor.Name == "author")
                                                {
                                                    AuthorStruct temp = new AuthorStruct();
                                                    temp.Author = childAuthor.InnerText;
                                                    temp.Comment = (childAuthor.Attributes["comment"] == null) ? "" : childAuthor.Attributes["comment"].Value;
                                                    temp.Website = (childAuthor.Attributes["url"] == null) ? "" : childAuthor.Attributes["url"].Value;
                                                    temp.Email = (childAuthor.Attributes["email"] == null) ? "" : childAuthor.Attributes["email"].Value;
                                                    values.Add(temp);
                                                }
                                            }
                                        }
                                        if (values.Count > 0 && key != "")
                                        {
                                            KeyValuePair<string, AuthorStruct[]> k = new KeyValuePair<string, AuthorStruct[]>(key, values.ToArray());
                                            cpi.CreditsParts.Add(k);
                                        }
                                    }
                                }
                            }
                            break;
                    }
                }
            }
            return cpi;
        }
Esempio n. 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);
        }
Esempio n. 3
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;
        }
Esempio n. 4
0
        private static ConfigPackInformation IterateThroughHead(XmlNode node, ConfigPackInformation cpi)
        {
            if (node.HasChildNodes)
            {
                foreach (XmlNode child in node.ChildNodes)
                {
                    switch (child.Name)
                    {
                    case ("config"):
                        cpi.PackName = child.Attributes["name"].Value;
                        break;

                    case ("description"):
                        cpi.Description = child.InnerText;
                        break;

                    case ("icon"):
                        cpi.IconURL = child.Attributes["img"].Value;
                        break;

                    case ("splash"):
                        cpi.SplashURL = child.Attributes["img"].Value;;
                        break;

                    case ("smbx64"):
                        if (child.Attributes["true"] != null)
                        {
                            cpi.IsSMBX64 = (child.Attributes["true"].Value == "1") ? true : false;
                        }
                        break;

                    case ("license"):
                        cpi.License = child.InnerText;
                        break;

                    case ("credits"):
                        if (child.HasChildNodes)
                        {
                            foreach (XmlNode partNode in child.ChildNodes)
                            {
                                if (partNode.Name == "part")
                                {
                                    string key = "";
                                    List <AuthorStruct> values = new List <AuthorStruct>();

                                    //XmlNode partNode = node.ChildNodes;
                                    key = (partNode.Attributes["name"].Value == null) ? "" : partNode.Attributes["name"].Value;
                                    if (partNode.HasChildNodes)
                                    {
                                        foreach (XmlNode childAuthor in partNode.ChildNodes)
                                        {
                                            if (childAuthor.Name == "author")
                                            {
                                                AuthorStruct temp = new AuthorStruct();
                                                temp.Author  = childAuthor.InnerText;
                                                temp.Comment = (childAuthor.Attributes["comment"] == null) ? "" : childAuthor.Attributes["comment"].Value;
                                                temp.Website = (childAuthor.Attributes["url"] == null) ? "" : childAuthor.Attributes["url"].Value;
                                                temp.Email   = (childAuthor.Attributes["email"] == null) ? "" : childAuthor.Attributes["email"].Value;
                                                values.Add(temp);
                                            }
                                        }
                                    }
                                    if (values.Count > 0 && key != "")
                                    {
                                        KeyValuePair <string, AuthorStruct[]> k = new KeyValuePair <string, AuthorStruct[]>(key, values.ToArray());
                                        cpi.CreditsParts.Add(k);
                                    }
                                }
                            }
                        }
                        break;
                    }
                }
            }
            return(cpi);
        }