public IConfiguration GetConfiguration(Type providerType) { if (providerType == null) { throw new ArgumentNullException(nameof(providerType)); } var fullName = providerType.FullName; var alias = ProviderAliasUtilities.GetAlias(providerType); var configurationBuilder = new ConfigurationBuilder(); foreach (var configuration in _configurations) { var sectionFromFullName = configuration.Configuration.GetSection(fullName); if (sectionFromFullName.Exists()) { configurationBuilder.AddConfiguration(sectionFromFullName); } if (!string.IsNullOrWhiteSpace(alias)) { var sectionFromAlias = configuration.Configuration.GetSection(alias); if (sectionFromAlias.Exists()) { configurationBuilder.AddConfiguration(sectionFromAlias); } } } return(configurationBuilder.Build()); }
public IConfiguration GetConfiguration(Type providerType) { ThrowHelper.ThrowIfNull(providerType); string fullName = providerType.FullName !; string?alias = ProviderAliasUtilities.GetAlias(providerType); var configurationBuilder = new ConfigurationBuilder(); foreach (LoggingConfiguration configuration in _configurations) { IConfigurationSection sectionFromFullName = configuration.Configuration.GetSection(fullName); configurationBuilder.AddConfiguration(sectionFromFullName); if (!string.IsNullOrWhiteSpace(alias)) { IConfigurationSection sectionFromAlias = configuration.Configuration.GetSection(alias); configurationBuilder.AddConfiguration(sectionFromAlias); } } return(configurationBuilder.Build()); }