예제 #1
0
        private IEnumerable <Action <ApplicationConfiguration> > CustomizationsFor(ApplicationEnvironment environment)
        {
            if (_environments.TryGetValue(environment, out List <Action <ApplicationConfiguration> > customizations))
            {
                return(customizations);
            }

            return(_fallbacks);
        }
예제 #2
0
        internal EnvironmentConfiguration(ApplicationConfiguration application)
        {
            if (application == null)
            {
                throw new ArgumentNullException(nameof(application));
            }

            _environments = new Dictionary <ApplicationEnvironment, List <Action <ApplicationConfiguration> > >(3);
            _fallbacks    = new List <Action <ApplicationConfiguration> >(1);
            _current      = new AppConfigRuntimeSettings().Environment;

            Application = application;
        }
예제 #3
0
        public EnvironmentConfiguration Customize(ApplicationEnvironment environment, Action <ApplicationConfiguration> customization)
        {
            if (environment == null)
            {
                throw new ArgumentNullException(nameof(environment));
            }
            if (customization == null)
            {
                throw new ArgumentNullException(nameof(customization));
            }

            if (!_environments.TryGetValue(environment, out List <Action <ApplicationConfiguration> > customizations))
            {
                customizations = _environments[environment] = new List <Action <ApplicationConfiguration> >(1);
            }

            customizations.Add(customization);

            return(this);
        }
예제 #4
0
        /// <summary>
        /// By default the current environment will be read from the current Application Configuration File (.config) using the built-in <see cref="System.Configuration.ConfigurationManager"/> class (AppSettings).
        /// Use this method to override that to behaviour.
        /// </summary>
        public EnvironmentConfiguration OverrideCurrent(ApplicationEnvironment environment)
        {
            _current = environment ?? throw new ArgumentNullException(nameof(environment));

            return(this);
        }