Exemplo n.º 1
0
        /// <summary>Gets a configuration by it's <paramref name="name"/>.</summary>
        /// <param name="name">The name of the configuration to obtain.</param>
        /// <returns>Configuration section of a given <paramref name="name"/> or empty configuration.</returns>
        public static ConfigurationSectionHandler GetConfiguration(string name)
        {
#if NETSTANDARD16
            ConfigurationSectionHandler result;
            if (!_configurations.TryGetValue(name, out result))
            {
                _configurations[name] = result = new ConfigurationSectionHandler();
                var configurationBinder = new ConfigureFromConfigurationOptions <ConfigurationSectionHandler>(Configuration.GetSection(name));
                try
                {
                    configurationBinder.Configure(result);
                }
                catch (TargetInvocationException error)
                {
                    throw error.InnerException;
                }
            }

            return(result);
#else
            return((ConfigurationSectionHandler)ConfigurationManager.GetSection(name) ?? new ConfigurationSectionHandler());
#endif
        }
 public void Setup()
 {
     _configuration = (ConfigurationSectionHandler)ConfigurationManager.GetSection("romanticWeb");
 }