コード例 #1
0
ファイル: RepackConfig.cs プロジェクト: droidsde/game
        public void loadConfig()
        {
            {
                XmlDocument xd = new XmlDocument();
                xd.Load(Path.Combine(Application.StartupPath, "config/channelList.xml"));

                XmlNodeList xnList = xd.SelectNodes("config/channelList/channel");

                ChannelList.Clear();
                foreach (XmlNode xn in xnList)
                {
                    ChannelItem item = new ChannelItem();
                    item.ChannelName = xn.SelectSingleNode("channelName").InnerText;
                    item.ChannelId   = xn.SelectSingleNode("channelId").InnerText;
                    ChannelList.Add(item);
                }
            }

            {
                XmlDocument xd = new XmlDocument();
                xd.Load(Path.Combine(Application.StartupPath, "config/packageList.xml"));

                XmlNodeList xnList = xd.SelectNodes("config/packageList/package");
                PackageList.Clear();
                foreach (XmlNode xn in xnList)
                {
                    PackageItem item = new PackageItem();
                    item.Title               = xn.SelectSingleNode("pkgTitle").InnerText;
                    item.PackageName         = xn.SelectSingleNode("pkgName").InnerText;
                    item.AppName             = xn.SelectSingleNode("AppName").InnerText;
                    item.ResourceDelete      = xn.SelectSingleNode("ResourceDelete").InnerText;
                    item.ResourceEncrypt     = xn.SelectSingleNode("ResourceEncrypt").InnerText;
                    item.ResourceNormal      = xn.SelectSingleNode("ResourceNormal").InnerText;
                    item.WinPhoneDescription = xn.SelectSingleNode("WinPhoneDescription").InnerText;
                    item.WinPhoneProductID   = xn.SelectSingleNode("WinPhoneProductID").InnerText;

                    XmlNodeList metaDataList = xn.SelectNodes("metaData/item");
                    foreach (XmlNode metaData in metaDataList)
                    {
                        string k = metaData.Attributes["name"].Value;
                        string v = metaData.Attributes["value"].Value;
                        item.MetaData.Add(k, v);
                    }

                    PackageList.Add(item);
                }
            }


            {
                XmlDocument xd = new XmlDocument();
                xd.Load(Path.Combine(Application.StartupPath, "config/enableList.xml"));

                XmlNodeList xnList = xd.SelectNodes("config/enableList/item");
                foreach (XmlNode xn in xnList)
                {
                    switch (xn.Attributes["name"].Value)
                    {
                    case "EnableMM":
                        EnableMM = xn.Attributes["value"].Value.Equals("true");
                        break;

                    case "EnableCopyFile":
                        EnableCopyFile = xn.Attributes["value"].Value.Equals("true");
                        break;

                    case "DeleteTemp":
                        DeleteTemp = xn.Attributes["value"].Value.Equals("true");
                        break;

                    default:
                        break;
                    }
                }

                xnList = xd.SelectNodes("config/encryptConfig/item");
                foreach (XmlNode xn in xnList)
                {
                    switch (xn.Attributes["name"].Value)
                    {
                    case "AllExts":
                    {
                        EncryptCfg.AllExts.Clear();
                        string   attrValue = xn.Attributes["value"].Value;
                        string[] strArr    = attrValue.Split(';');
                        foreach (string item in strArr)
                        {
                            EncryptCfg.AllExts.Add("." + item);
                        }
                    }
                    break;

                    case "PartExts":
                    {
                        EncryptCfg.PartExts.Clear();
                        string   attrValue = xn.Attributes["value"].Value;
                        string[] strArr    = attrValue.Split(';');
                        foreach (string item in strArr)
                        {
                            EncryptCfg.PartExts.Add("." + item);
                        }
                    }
                    break;

                    case "PartLength":
                        EncryptCfg.PartLength = Convert.ToInt32(xn.Attributes["value"].Value);
                        break;

                    default:
                        break;
                    }
                }


                CopyFileList.Clear();
                xnList = xd.SelectNodes("config/copyFileList/item");
                foreach (XmlNode xn in xnList)
                {
                    CopyFileList.Add(xn.Attributes["name"].Value);
                }

                ResourceFileList.Clear();
                xnList = xd.SelectNodes("config/resourceFileList/item");
                foreach (XmlNode xn in xnList)
                {
                    ResourceFileList.Add(xn.Attributes["name"].Value);
                }

                WinPhoneFileList.Clear();
                xnList = xd.SelectNodes("config/winPhoneFileList/item");
                foreach (XmlNode xn in xnList)
                {
                    WinPhoneFileList.Add(xn.Attributes["name"].Value);
                }
            }
        }