Search Results for

    Show / Hide Table of Contents

    Method AddCustomEnv

    | Improve this Doc View Source

    AddCustomEnv(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

    services is null.

    | Improve this Doc View Source

    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

    services is null.

    • Improve this Doc
    • View Source
    In This Article
    Back to top Copyright 2022-2023 DotEnv.Core