private void button3_Click(object sender, EventArgs e) { string xml = HelperFunctions.FileFunctions.OpenTextFile(Path.Combine(Application.StartupPath, txtConfigFileName.Text)); ConfigurationFile wConfigurationFile = Fwk.Configuration.Common.ConfigurationFile.GetFromXml <ConfigurationFile>(xml); xmlConfitFile.ForeColor = Color.Red; xmlConfitFile.Text = wConfigurationFile.GetXml(); }
private void button4_Click(object sender, EventArgs e) { try { ConfigurationFile wConfigurationFile = (ConfigurationFile)HelperFunctions.SerializationFunctions.DeserializeFromXml(typeof(ConfigurationFile), xmlConfitFile.Text); xmlConfitFile.ForeColor = Color.Blue; xmlConfitFile.Text = wConfigurationFile.GetXml(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void btnLoadConfigFile_Click(object sender, EventArgs e) { Fwk.Configuration.Common.Key wKey; Fwk.Configuration.Common.Groups wGroups; Fwk.Configuration.Common.Group wGroup; wGroups = new Fwk.Configuration.Common.Groups(); ConfigurationFile wConfigurationFile = new ConfigurationFile(); wConfigurationFile.CurrentVersion = "1.1"; wConfigurationFile.Encrypted = false; wGroup = new Fwk.Configuration.Common.Group(); wGroup.Name = "G1"; wKey = new Fwk.Configuration.Common.Key(); wKey.Name = "K1"; wKey.Value.Text = "aaaaaaaaaaaaaaaaa"; wGroup.Keys.Add(wKey); wKey = new Fwk.Configuration.Common.Key(); wKey.Name = "K2"; wKey.Value.Text = "cccccccccccccccccccccccccccccccccc"; wGroup.Keys.Add(wKey); wGroups.Add(wGroup); wGroup = new Fwk.Configuration.Common.Group(); wGroup.Name = "G2"; wKey = new Fwk.Configuration.Common.Key(); wKey.Name = "K1"; wKey.Value.Text = "aaaaaaaaaaaaaaaaa"; wGroup.Keys.Add(wKey); wKey = new Fwk.Configuration.Common.Key(); wKey.Name = "K2"; wKey.Value.Text = "cccccccccccccccccccccccccccccccccc"; wGroup.Keys.Add(wKey); wGroups.Add(wGroup); wConfigurationFile.Groups = wGroups; xmlConfitFile.Text = wConfigurationFile.GetXml(); xmlConfitFile.ForeColor = Color.Green; }
/// <summary> /// Cambia el nombre de un grupo.- /// </summary> /// <param name="provider">Proveedor de configuracion</param> /// <param name="groupName">Nombre del grupo</param> /// <param name="newGroupName">Nuevo nombre del grupo</param> internal static void ChangeGroupName(ConfigProviderElement provider, string groupName, string newGroupName) { ConfigurationFile wConfigurationFile = GetConfig(provider); Group g = wConfigurationFile.Groups.GetFirstByName(groupName); g.Name = newGroupName; try { FileFunctions.SaveTextFile(wConfigurationFile.FileName, wConfigurationFile.GetXml(), false); } catch (System.UnauthorizedAccessException) { TechnicalException te = new TechnicalException(string.Concat("No tiene permiso para actualizar el archivo ", provider.BaseConfigFile)); te.ErrorId = "8008"; Fwk.Exceptions.ExceptionHelper.SetTechnicalException(te, typeof(LocalFileConfigurationManager)); throw te; } }
private void btnLoadConfigFile_Click(object sender, EventArgs e) { Fwk.Configuration.Common.Key wKey; Fwk.Configuration.Common.Groups wGroups; Fwk.Configuration.Common.Group wGroup; wGroups = new Fwk.Configuration.Common.Groups(); ConfigurationFile wConfigurationFile = new ConfigurationFile(); wConfigurationFile.CurrentVersion = "1.1"; wConfigurationFile.Encrypted = false; wGroup = new Fwk.Configuration.Common.Group(); wGroup.Name = "G1"; wKey = new Fwk.Configuration.Common.Key(); wKey.Name = "K1"; wKey.Value.Text= "aaaaaaaaaaaaaaaaa"; wGroup.Keys.Add(wKey); wKey = new Fwk.Configuration.Common.Key(); wKey.Name = "K2"; wKey.Value.Text = "cccccccccccccccccccccccccccccccccc"; wGroup.Keys.Add(wKey); wGroups.Add(wGroup); wGroup = new Fwk.Configuration.Common.Group(); wGroup.Name = "G2"; wKey = new Fwk.Configuration.Common.Key(); wKey.Name = "K1"; wKey.Value.Text = "aaaaaaaaaaaaaaaaa"; wGroup.Keys.Add(wKey); wKey = new Fwk.Configuration.Common.Key(); wKey.Name = "K2"; wKey.Value.Text = "cccccccccccccccccccccccccccccccccc"; wGroup.Keys.Add(wKey); wGroups.Add(wGroup); wConfigurationFile.Groups = wGroups; xmlConfitFile.Text = wConfigurationFile.GetXml(); xmlConfitFile.ForeColor = Color.Green; }