Пример #1
0
        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);
        }
Пример #2
0
        private static ConfigChange LoadChanges(string fileName)
        {
            string jsonStr              = File.ReadAllText(fileName);
            JavaScriptSerializer js     = new JavaScriptSerializer();
            ConfigChange         script = js.Deserialize <ConfigChange>(jsonStr);

            return(script);
        }
Пример #3
0
        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);
        }
Пример #4
0
        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);
        }
Пример #5
0
        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);
        }