Class ServiceCollectionExtensions
- Namespace
- OpenSettings.Extensions
- Assembly
- OpenSettings.dll
Provides extension methods to configure and add OpenSettings services to an IServiceCollection.
public static class ServiceCollectionExtensions
- Inheritance
-
ServiceCollectionExtensions
- Inherited Members
Methods
AddOpenSettings(IServiceCollection, OpenSettingsConfiguration, ProviderInfo)
Adds OpenSettings services to the application's IServiceCollection. This registers services necessary to run OpenSettings, based on the inherited ISettings types and the registration type.
public static IServiceCollection AddOpenSettings(this IServiceCollection services, OpenSettingsConfiguration openSettingsConfiguration, ProviderInfo providerInfo)
Parameters
services
IServiceCollectionThe IServiceCollection to which OpenSettings services will be added.
openSettingsConfiguration
OpenSettingsConfigurationThe configuration that governs the behavior of OpenSettings (such as the service type: Provider or Consumer).
providerInfo
ProviderInfoInformation about the provider being registered.
Returns
- IServiceCollection
The IServiceCollection with OpenSettings services registered.
Exceptions
- ArgumentNullException
Thrown if
openSettingsConfiguration
is null.
Configure(IServiceCollection, IConfigurationSection, Type)
public static IServiceCollection Configure(this IServiceCollection services, IConfigurationSection section, Type optionsType)
Parameters
services
IServiceCollectionsection
IConfigurationSectionoptionsType
Type
Returns
ConfigureOpenSettings(IServiceCollection, IConfiguration)
Configures OpenSettings for the application by iterating over the OpenSettings.Constants.FullNameToLocalSetting and registering each setting type in the IServiceCollection based on the configuration.
This method is typically called during the UseOpenSettingsAsync(IHostBuilder, OpenSettingsConfiguration, params Type[]) extension to initialize OpenSettings configuration.
public static IServiceCollection ConfigureOpenSettings(this IServiceCollection services, IConfiguration configuration)
Parameters
services
IServiceCollectionThe IServiceCollection to which the OpenSettings services will be added.
configuration
IConfigurationThe IConfiguration instance used to configure the settings.
Returns
- IServiceCollection
The IServiceCollection with OpenSettings services configured.