Example #1
0
        public static void UpdateXml(Configurator configs)
        {
            var doc = XElement.Load(EnviormentInfo.GetXmlPathConf());

            #region Test Confs
            //Configurator configs = new Configurator()
            //{
            //    AlertColor = new _Config { Name = "AlertColor", Value = "Teste" },
            //    AlertTime = new _Config { Name = "AlertTime", Value = "Teste" },
            //    FadeAsDefault = new _Config { Name = "FadeAsDefault", Value = "Teste" },
            //    GadgetColor = new _Config { Name = "GadgetColor", Value = "Teste" },
            //    PopUpColor = new _Config { Name = "PopUpColor", Value = "Teste" },
            //    PopUpTime = new _Config { Name = "PopUpTime", Value = "Teste" },
            //    Server = new _Config { Name = "Server", Value = "Teste" },
            //};
            #endregion

            var confs = configs.GetConfs();

            confs.ForEach(conf =>
            {
                var elemento = doc
                               .Elements("Field")
                               .Where(e => e.Element("Name").Value == conf.Name)
                               .Single();

                elemento.SetElementValue("Value", conf.Value);
            });

            doc.Save(EnviormentInfo.GetXmlPathConf());
        }
        public static string GetString(string fieldName)
        {
            XDocument xdoc = XDocument.Load(EnviormentInfo.GetXmlPathConf());

            return((string)(
                       from el in xdoc.Descendants("Field")
                       where (string)el.Element("Name") == fieldName
                       select el.Element("Value")).FirstOrDefault());
        }