Created
May 17, 2017 11:32
-
-
Save dmitry-zaets/c3e5c9482e6df42cccc4828df392ad6a to your computer and use it in GitHub Desktop.
This file contains hidden or 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
public static void RegisterConfigurationOptions<TOptions>(this ContainerBuilder builder, IConfiguration config) where TOptions : class | |
{ | |
if (builder == null) | |
{ | |
throw new ArgumentNullException(nameof(builder)); | |
} | |
if (config == null) | |
{ | |
throw new ArgumentNullException(nameof(config)); | |
} | |
builder.RegisterInstance(new ConfigurationChangeTokenSource<TOptions>(config)) | |
.As<IOptionsChangeTokenSource<TOptions>>() | |
.SingleInstance(); | |
builder.RegisterInstance(new ConfigureFromConfigurationOptions<TOptions>(config)) | |
.As<IConfigureOptions<TOptions>>() | |
.SingleInstance(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment