コード例 #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;
            }
        }
コード例 #2
0
ファイル: Environments.cs プロジェクト: rocky0904/mozu-dotnet
        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);
            }
        }
コード例 #3
0
ファイル: Environments.cs プロジェクト: rocky0904/mozu-dotnet
 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);
     }
 }
コード例 #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;
     }
 }
コード例 #5
0
ファイル: Environments.cs プロジェクト: rocky0904/mozu-dotnet
 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)
     {
         //
     }
 }
コード例 #6
0
ファイル: Environments.cs プロジェクト: rocky0904/mozu-dotnet
        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.
            }
        }
コード例 #7
0
ファイル: Environments.cs プロジェクト: rocky0904/mozu-dotnet
 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)
     {
         //
     }
 }
コード例 #8
0
ファイル: Environments.cs プロジェクト: rocky0904/mozu-dotnet
        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.
            }

        } 
コード例 #9
0
ファイル: Environments.cs プロジェクト: rocky0904/mozu-dotnet
        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)
            {
                //
            }

        }
コード例 #10
0
ファイル: Environments.cs プロジェクト: rocky0904/mozu-dotnet
        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)
            {
                //
            }

        }