Exemplo n.º 1
0
        public static Environments GetConfigEnvironment()
        {
            //ConfigurationManager.RefreshSection("appSettings");
               // var envir = ConfigurationManager.AppSettings["Environment"];
            // Create configuration reader that reads the files once
            var sdkConfigFile = ConfigurationManager.AppSettings["SDKConfig"];
            if (!File.Exists(sdkConfigFile))
                throw new FileNotFoundException(sdkConfigFile);
            var configFileReader = new CustomConfigurationFileReader(sdkConfigFile);
            var config = configFileReader.Config;

            var envir = config.AppSettings.Settings["Environment"].Value;

            if (string.IsNullOrEmpty(envir))
            {
                envir = "SI";
            }
            switch (envir.ToUpper())
            {
                case "DEV":
                    return Environments.Dev;
                case "CI":
                    return Environments.CI;
                case "SI":
                    return Environments.SI;
                case "QA":
                    return Environments.QA;
                case "DEMO":
                    return Environments.Demo;
                case "PROD":
                    return Environments.Prod;
                default:
                    return Environments.SI;
            }
        }
Exemplo n.º 2
0
        public static Environments GetConfigEnvironment()
        {
            //ConfigurationManager.RefreshSection("appSettings");
            // var envir = ConfigurationManager.AppSettings["Environment"];
            // Create configuration reader that reads the files once
            var configFile = ConfigurationManager.AppSettings["SDKConfig"];

            if (!File.Exists(configFile))
            {
                throw new Exception(configFile + " not found");
            }

            var sdkConfigFile = ConfigurationManager.AppSettings["SDKConfig"];

            if (!File.Exists(sdkConfigFile))
            {
                throw new FileNotFoundException(sdkConfigFile);
            }
            var configFileReader = new CustomConfigurationFileReader(sdkConfigFile);
            var config           = configFileReader.Config;

            var envir = config.AppSettings.Settings["Environment"].Value;

            if (string.IsNullOrEmpty(envir))
            {
                envir = "SI";
            }
            switch (envir.ToUpper())
            {
            case "DEV":
                return(Environments.Dev);

            case "CI":
                return(Environments.CI);

            case "SI":
                return(Environments.SI);

            case "QA":
                return(Environments.QA);

            case "DEMO":
                return(Environments.Demo);

            case "PROD":
                return(Environments.Prod);

            default:
                return(Environments.SI);
            }
        }
Exemplo n.º 3
0
 public static string GetConfigValueByEnvironment(Environments environment, string keyPart)
 {
     try
     {
         var sdkConfigFile    = ConfigurationManager.AppSettings["SDKConfig"];
         var configFileReader = new CustomConfigurationFileReader(sdkConfigFile);
         var config           = configFileReader.Config;
         var setting          = config.AppSettings.Settings[keyPart + "_" + environment.ToString()].Value;
         return(setting);
     }
     catch (Exception)
     {
         return(null);
     }
 }
Exemplo n.º 4
0
 public static string GetConfigValueByEnvironment(Environments environment, string keyPart)
 {
     try
     {
         var sdkConfigFile = ConfigurationManager.AppSettings["SDKConfig"];
         var configFileReader = new CustomConfigurationFileReader(sdkConfigFile);
         var config = configFileReader.Config;
         var setting = config.AppSettings.Settings[keyPart + "_" + environment.ToString()].Value;
         return setting;
     }
     catch (Exception)
     {
         return null;
     }
 }
Exemplo n.º 5
0
 public static void UpdateConfigValueByEnvironment(Environments environment, string keyPart, string value)
 {
     try
     {
         var sdkConfigFile    = ConfigurationManager.AppSettings["SDKConfig"];
         var configFileReader = new CustomConfigurationFileReader(sdkConfigFile);
         var config           = configFileReader.Config;
         //System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
         config.AppSettings.Settings.Remove(keyPart + "_" + environment.ToString());
         config.AppSettings.Settings.Add(keyPart + "_" + environment.ToString(), value);
         config.Save(ConfigurationSaveMode.Modified);
     }
     catch (Exception)
     {
         //
     }
 }
Exemplo n.º 6
0
        public static void UpdateConfigSetting(string key, string value)
        {
            try
            {
                var sdkConfigFile    = ConfigurationManager.AppSettings["SDKConfig"];
                var configFileReader = new CustomConfigurationFileReader(sdkConfigFile);
                var config           = configFileReader.Config;

                config.AppSettings.Settings.Remove(key);
                config.AppSettings.Settings.Add(key, value);
                config.Save(ConfigurationSaveMode.Modified);
            }
            catch
            {
                // just means the test cases do not have the same App.config as was setup by the default SDK test.
            }
        }
Exemplo n.º 7
0
 public static void UpdateConfigValueByEnvironment(string keyPart, string value)
 {
     try
     {
         var environment      = GetConfigEnvironment();
         var sdkConfigFile    = ConfigurationManager.AppSettings["SDKConfig"];
         var configFileReader = new CustomConfigurationFileReader(sdkConfigFile);
         var config           = configFileReader.Config;
         config.AppSettings.Settings.Remove(keyPart + "_" + environment.ToString());
         config.AppSettings.Settings.Add(keyPart + "_" + environment.ToString(), value);
         config.Save(ConfigurationSaveMode.Modified);
         ConfigurationManager.RefreshSection("appSettings");
     }
     catch (Exception)
     {
         //
     }
 }
Exemplo n.º 8
0
        public static void UpdateConfigSetting(string key, string value)
        {
            try
            {
                var sdkConfigFile = ConfigurationManager.AppSettings["SDKConfig"];
                var configFileReader = new CustomConfigurationFileReader(sdkConfigFile);
                var config = configFileReader.Config;

                config.AppSettings.Settings.Remove(key);
                config.AppSettings.Settings.Add(key, value);
                config.Save(ConfigurationSaveMode.Modified);
            }
            catch
            {
                // just means the test cases do not have the same App.config as was setup by the default SDK test.
            }

        } 
Exemplo n.º 9
0
        public static void UpdateConfigValueByEnvironment(Environments environment, string keyPart, string value)
        {
            try
            {
                var sdkConfigFile = ConfigurationManager.AppSettings["SDKConfig"];
                var configFileReader = new CustomConfigurationFileReader(sdkConfigFile);
                var config = configFileReader.Config;
                //System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
                config.AppSettings.Settings.Remove(keyPart + "_" + environment.ToString());
                config.AppSettings.Settings.Add(keyPart + "_" + environment.ToString(), value);
                config.Save(ConfigurationSaveMode.Modified);
            }
            catch (Exception)
            {
                //
            }

        }
Exemplo n.º 10
0
        public static void UpdateConfigValueByEnvironment(string keyPart, string value)
        {
            try
            {
                var environment = GetConfigEnvironment();
                var sdkConfigFile = ConfigurationManager.AppSettings["SDKConfig"];
                var configFileReader = new CustomConfigurationFileReader(sdkConfigFile);
                var config = configFileReader.Config;
                config.AppSettings.Settings.Remove(keyPart + "_" + environment.ToString());
                config.AppSettings.Settings.Add(keyPart + "_" + environment.ToString(), value);
                config.Save(ConfigurationSaveMode.Modified);
                ConfigurationManager.RefreshSection("appSettings");

            }
            catch (Exception)
            {
                //
            }

        }