/// <summary>
        /// Register a configuration source within the configuration context.
        /// </summary>
        /// <param name="source">The configuration source.</param>
        /// <returns>
        /// A configurator which can be used to further configure the source.
        /// </returns>
        public IConfigurationRegistration Register(IConfigurationSource source)
        {
            if (disposed)
            {
                throw new ObjectDisposedException("this");
            }

            if (source == null)
            {
                throw new ArgumentNullException(nameof(source));
            }

            if (initialized)
            {
                throw new InvalidOperationException("Cannot register new configuration sources once the context has been initialized");
            }

            var descriptor   = new ConfigurationDescriptor(source);
            var registration = new ConfigurationRegistration(descriptor);

            sources.AddIfMissing(descriptor);

            return(registration);
        }
Exemplo n.º 2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ConfigurationRegistration"/> class.
 /// </summary>
 /// <param name="configuration">The configuration.</param>
 public ConfigurationRegistration(ConfigurationDescriptor configuration) => descriptor = configuration;