Skip to content

Commit

Permalink
LoadConfigurationFromSection should RegisterConfigSettings without co…
Browse files Browse the repository at this point in the history
…nfiguration assign (#627)
  • Loading branch information
snakefoot authored Sep 29, 2022
1 parent 0e69f8c commit 7de383b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public static class SetupBuilderExtensions
/// </summary>
public static ISetupBuilder LoadConfigurationFromSection(this ISetupBuilder setupBuilder, Microsoft.Extensions.Configuration.IConfiguration configuration, string configSection = "NLog")
{
setupBuilder.SetupExtensions(ext => ext.RegisterExtensionsLogging(configuration));
if (!string.IsNullOrEmpty(configSection))
{
var nlogConfig = configuration.GetSection(configSection);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@ public static class SetupExtensionsBuilderExtensions
public static ISetupExtensionsBuilder RegisterConfigSettings(this ISetupExtensionsBuilder setupBuilder, IConfiguration configuration)
{
ConfigSettingLayoutRenderer.DefaultConfiguration = configuration;
return setupBuilder.RegisterExtensionsLogging(configuration);
}

internal static ISetupExtensionsBuilder RegisterExtensionsLogging(this ISetupExtensionsBuilder setupBuilder, IConfiguration configuration)
{
if (ConfigSettingLayoutRenderer.DefaultConfiguration is null)
{
ConfigSettingLayoutRenderer.DefaultConfiguration = configuration;
}
return setupBuilder.RegisterLayoutRenderer<ConfigSettingLayoutRenderer>("configsetting").RegisterLayoutRenderer<MicrosoftConsoleLayoutRenderer>("MicrosoftConsoleLayout");
}
}
Expand Down

0 comments on commit 7de383b

Please sign in to comment.