Esempio n. 1
0
        private void LoadConf()
        {
            log.WriteFileLog("加载配置文件");
            XmlDocument xmldoc = new XmlDocument();

            try
            {
                xmldoc.Load(conf);
            }
            catch (System.IO.FileNotFoundException)
            {
                MessageBox.Show("配置文件不存在,程序退出!");
                Application.Exit();
            }

            XmlElement root = xmldoc.DocumentElement;

            XmlNode     xn  = root.SelectSingleNode("Products");
            XmlNodeList xnl = xn.ChildNodes;

            foreach (XmlNode x in xnl)
            {
                if (x.Attributes["enable"].Value == "false")
                {
                    continue;
                }

                // 跳过注释,否则格式不对,会报错
                if (x.NodeType == XmlNodeType.Comment)
                {
                    continue;
                }

                BaseConf c = null;
                if (x.Attributes["type"].Value == "cres")
                {
                    c = new CresConf(x);
                }
                else if (x.Attributes["type"].Value == "febs")
                {
                    c = new FebsConf(x);
                }

                if (c != null)
                {
                    Configs.Add(c);
                }
            }

            log.WriteFileLog("配置初始化完成");
        }
Esempio n. 2
0
        private void LoadConf()
        {
            log.WriteFileLog("加载配置文件");
            XmlDocument xmldoc = new XmlDocument();
            try
            {
                xmldoc.Load(conf);
            }
            catch(System.IO.FileNotFoundException)
            {
                MessageBox.Show("配置文件不存在,程序退出!");
                Application.Exit();
            }

            XmlElement root = xmldoc.DocumentElement;

            XmlNode xn = root.SelectSingleNode("Products");
            XmlNodeList xnl = xn.ChildNodes;
            foreach (XmlNode x in xnl)
            {
                if (x.Attributes["enable"].Value == "false")
                    continue;

                // 跳过注释,否则格式不对,会报错
                if (x.NodeType == XmlNodeType.Comment)
                    continue;

                BaseConf c = null;
                if (x.Attributes["type"].Value == "cres")
                {
                    c = new CresConf(x);
                }
                else if (x.Attributes["type"].Value == "febs")
                {
                    c = new FebsConf(x);
                }

                if (c != null)
                    Configs.Add(c);
            }

            log.WriteFileLog("配置初始化完成");
        }