private static void SaveChanges(ConfigChange script, string stringFileName) { JavaScriptSerializer js = new JavaScriptSerializer(); var jsonString = js.Serialize(script); jsonString = JSONFormatter.FormatOutput(jsonString); File.WriteAllText(stringFileName, jsonString); }
private static ConfigChange LoadChanges(string fileName) { string jsonStr = File.ReadAllText(fileName); JavaScriptSerializer js = new JavaScriptSerializer(); ConfigChange script = js.Deserialize <ConfigChange>(jsonStr); return(script); }
private static ConfigChange CreateChangesArchive() { var change = new ConfigChange(); change.Variables = new List <Variable>(); change.Changes = new List <Change>(); change.Variables.Add(new Variable() { Name = "machine", Value = "DK01SV1547" }); change.Changes.Add(new Change() { Value = "http://machine/C1Api/", Attribute = "value", XPath = "/configuration/appSettings/add[@key='api.Address']" }); return(change); }
public void Convert(string configFile, ConfigChange changeDefinition) { if (!File.Exists(configFile)) { throw new FileNotFoundException($"file {configFile} not found"); } XmlDocument xmlDoc = new XmlDocument(); xmlDoc.PreserveWhitespace = true; xmlDoc.Load(configFile); foreach (var configChange in changeDefinition.Changes) { ApplyConfigChange(xmlDoc, configChange, changeDefinition.Variables); } xmlDoc.Save(configFile); }
private static ConfigChange CreateChangesC1Api() { var change = new ConfigChange(); change.Variables = new List <Variable>(); change.Changes = new List <Change>(); change.Variables.Add(new Variable() { Name = "machine", Value = "DK01SV1547" }); change.Changes.Add(new Change() { Value = "http://machine/C1", Attribute = "value", XPath = "/configuration/appSettings/add[@key='C1Url']" }); change.Changes.Add(new Change() { Value = "http://machine/ConfigurationServer/Connectivity.svc/basic", Attribute = "address", XPath = "/configuration/system.serviceModel/client/endpoint[@binding='basicHttpBinding']" }); change.Changes.Add(new Change() { Value = "net.tcp://machine/CoricDataCommunicationService/MessageProcessor.svc/tcp", Attribute = "address", XPath = "/configuration/system.serviceModel/client/endpoint[@binding='netTcpBinding']" }); return(change); }