Beispiel #1
0
        static void Main(string[] args)
        {
            DevModeSetting _devMode = new DevModeSetting();

                #if (DEBUG)
            _devMode = DevModeSettingsHandler.GetDevModeSetting("debug");
            ConfigurationManager.AppSettings["webServiceUrl"] = _devMode.WebServiceUrl;
                #endif

            Console.WriteLine(ConfigurationManager.AppSettings["webServiceUrl"]);
            Console.ReadLine();
        }
Beispiel #2
0
        public static DevModeSetting GetDevModeSetting(string devMode)
        {
            string section = "DevModeSettings/" + devMode;

            ConfigurationManager.RefreshSection(section);     // This must be done to flush out previous overrides
            DevModeSetting config = (DevModeSetting)ConfigurationManager.GetSection(section);

            if (config != null)
            {
                // Perform validation etc...
            }
            else
            {
                throw new ConfigurationErrorsException("oops!");
            }

            return(config);
        }