Created
March 28, 2018 18:16
-
-
Save configureappio/6558f9776ae60aa3f1d888072a37cc12 to your computer and use it in GitHub Desktop.
Example of changes required to Startup.cs to use the reader for the configuration mapping and the bridge as the implementation used by controller
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
public class Startup | |
{ | |
// Other methods omitted for brevity in example | |
public void ConfigureServices(IServiceCollection services) | |
{ | |
services.AddMvc(); | |
services.AddOptions(); | |
// use the reader class to map the configuration | |
services.Configure<MyAppSettingsReader>(Configuration.GetSection("MyAppSettings")); | |
// but use the bridge class as the implementation of IMyAppSettings | |
services.AddTransient<IMyAppSettings, MyAppSettingsBridge>(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment