Method AddCustomEnv
| Improve this Doc View SourceAddCustomEnv(IServiceCollection, String, String)
Adds the environment vars based on the environment (development, test, staging or production). This registers IEnvReader as a singleton and calls the LoadEnv() method.
Declaration
public static IEnvReader AddCustomEnv(this IServiceCollection services, string basePath = null, string environmentName = null)
Parameters
| Type | Name | Description |
|---|---|---|
| IServiceCollection | services | The service collection. |
| String | basePath | The base path where the .env files will be located. |
| String | environmentName | The name of the environment. |
Returns
| Type | Description |
|---|---|
| IEnvReader | An instance that allows access to the environment variables. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException |
|
AddCustomEnv<TSettings>(IServiceCollection, String, String)
Adds the environment vars based on the environment (development, test, staging or production).
This registers TSettings as a singleton and calls the LoadEnv() method.
Declaration
public static TSettings AddCustomEnv<TSettings>(this IServiceCollection services, string basePath = null, string environmentName = null)
where TSettings : class, new()
Parameters
| Type | Name | Description |
|---|---|---|
| IServiceCollection | services | The service collection. |
| String | basePath | The base path where the .env files will be located. |
| String | environmentName | The name of the environment. |
Returns
| Type | Description |
|---|---|
| TSettings | An instance that allows access to the environment variables. |
Type Parameters
| Name | Description |
|---|---|
| TSettings | The type of the new instance to bind. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException |
|