Created
September 30, 2023 09:09
-
-
Save MichalGrzegorzak/da1f4f560fc7a2b96288839d0cbbe952 to your computer and use it in GitHub Desktop.
AddConfigOptionsFromConfigSection
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
internal static IServiceCollection AddConfigOptionsFromConfigSection<T>(this IServiceCollection services, string configSectionName) where T : class | |
{ | |
services.AddOptions<T>().Configure<IConfiguration>((settings, configuration) => | |
{ | |
configuration.GetSection(configSectionName).Bind(settings); | |
}); | |
return services; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment