Readme - Code Samples for Chapter 15, Dependency Injection and configuration
November 28, 2022 ยท View on GitHub
Dependency Injection and Configuration gives detail about how the Host class is used to configure a dependency injection container and the built-in options to retrieve configuration information from a .NET application with different configuration providers, including Azure App Configuration and user secrets.
This chapter contains the following code samples:
- WithDIContainer (with the DI container Microsoft.Extensions.DependencyInjection)
- WithHost (using the Host class)
- ServicesLifetime (creating scoped services, disposing of services)
- DIWithOptions (using the IOptions interface for instantiating services)
- DIWithConfiguration (using configuration files to configure the services)
- ConfigurationSample
- AzureAppConfigWebApp (configuration with Azure App Configuration)
Bash script for Azure App Configuration
.NET 7 Updates
.NET 7 includes the HostApplicationBuilder which simplifies creating the DI container.
More information
For code comments and issues please check Professional C#'s GitHub Repository
Please check my blog csharp.christiannagel.com for additional information for topics covered in the book.
Thank you!