Search Results for

    Show / Hide Table of Contents

    Method AddDotEnv

    | Improve this Doc View Source

    AddDotEnv(IServiceCollection)

    Adds the environment vars using a service. This registers IEnvReader as a singleton and calls the Load() method.

    Declaration
    public static IEnvReader AddDotEnv(this IServiceCollection services)
    Parameters
    Type Name Description
    IServiceCollection services

    The service collection.

    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

    AddDotEnv(IServiceCollection, String[])

    Adds the environment vars using a service. This registers IEnvReader as a singleton and calls the Load() method.

    Declaration
    public static IEnvReader AddDotEnv(this IServiceCollection services, params string[] paths)
    Parameters
    Type Name Description
    IServiceCollection services

    The service collection.

    String[] paths

    The .env files paths to add.

    Returns
    Type Description
    IEnvReader

    An instance that allows access to the environment variables.

    Exceptions
    Type Condition
    ArgumentNullException

    services, or paths is null.

    ArgumentException

    The length of the paths list is zero.

    | Improve this Doc View Source

    AddDotEnv<TSettings>(IServiceCollection)

    Adds the environment vars using a service. This registers TSettings as a singleton and calls the Load() method.

    Declaration
    public static TSettings AddDotEnv<TSettings>(this IServiceCollection services)
        where TSettings : class, new()
    Parameters
    Type Name Description
    IServiceCollection services

    The service collection.

    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

    AddDotEnv<TSettings>(IServiceCollection, String[])

    Adds the environment vars using a service. This registers TSettings as a singleton and calls the Load() method.

    Declaration
    public static TSettings AddDotEnv<TSettings>(this IServiceCollection services, params string[] paths)
        where TSettings : class, new()
    Parameters
    Type Name Description
    IServiceCollection services

    The service collection.

    String[] paths

    The .env files paths to add.

    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, or paths is null.

    ArgumentException

    The length of the paths list is zero.

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