Search Results for

    Show / Hide Table of Contents

    Interface IEnvLoader

    Represents the .env files loader.

    Namespace: DotEnv.Core
    Assembly: DotEnv.Core.dll
    Syntax
    public interface IEnvLoader

    Methods

    Name Description
    AddEnvFile(String)

    Adds an .env file in a collection.

    AddEnvFile(String, Boolean)

    Adds an .env file to a collection and indicates whether the .env file can be optional, or not.

    AddEnvFile(String, String)

    Adds an .env file with its encoding name in a collection.

    AddEnvFile(String, String, Boolean)

    Adds an .env file with its encoding name in a collection.

    AddEnvFile(String, Encoding)

    Adds an .env file with its encoding in a collection.

    AddEnvFile(String, Encoding, Boolean)

    Adds an .env file with its encoding in a collection.

    AddEnvFiles(String[])

    Adds the .env files in a collection.

    AllowAllEnvFilesOptional()

    Allows all .env files to be optional. This tells the loader not to raise an error in case the .env file is not found in any directory.

    AllowConcatDuplicateKeys(ConcatKeysOptions)

    Allows concatenating the values of the duplicate keys.

    AllowOverwriteExistingVars()

    Allows overwriting the existing variables of a specific provider (e.g., current process or a Dictionary<TKey,TValue>).

    AvoidModifyEnvironment()

    Avoids modifying the environment of the current process. When this method is used, the environment variables are obtained from a Dictionary<TKey,TValue> and not from the current process.

    DisableTrimEndKeys()

    Disables the trim at the end of the keys. This method will tell the parser not to remove trailing white spaces from the keys.

    DisableTrimEndValues()

    Disables the trim at the end of the values. This method will tell the parser not to remove trailing white spaces from the values.

    DisableTrimKeys()

    Disables the trim at the start and end of the keys.

    DisableTrimStartComments()

    Disables the trim at the start of the comments. This method will tell the parser not to remove leading white spaces from the comments.

    DisableTrimStartKeys()

    Disables the trim at the start of the keys. This method will tell the parser not to remove leading white spaces from the keys.

    DisableTrimStartValues()

    Disables the trim at the start of the values. This method will tell the parser not to remove leading white spaces from the values.

    DisableTrimValues()

    Disables the trim at the start and end of the values.

    EnableFileNotFoundException()

    Enables FileNotFoundException. This method tells the loader to throw an exception when one or more .env files are not found.

    IgnoreParentDirectories()

    Ignores search in parent directories. This tells the loader not to search in parent directories when the .env file is not in a directory.

    IgnoreParserException()

    Disables/ignores ParserException. This method tells the parser not to throw an exception when it encounters one or more errors.

    Load()

    Loads one or more .env files. By default, it will search for a file called .env.

    Load(out EnvValidationResult)

    Loads one or more .env files. By default, it will search for a file called .env.

    LoadEnv()

    Loads an .env file based on the environment (development, test, staging or production). This method will load these .env files in the following order:

    • .env.[environment].local (has the highest priority).
    • .env.local
    • .env.[environment]
    • .env (has the lowest priority).
    The environment is specified by the actual environment variable DOTNET_ENV.

    It should be noted that the default environment will be development or dev if the environment is never specified with DOTNET_ENV.

    LoadEnv(out EnvValidationResult)

    Loads an .env file based on the environment (development, test, staging or production). This method will load these .env files in the following order:

    • .env.[environment].local (has the highest priority).
    • .env.local
    • .env.[environment]
    • .env (has the lowest priority).
    The environment is specified by the actual environment variable DOTNET_ENV.

    It should be noted that the default environment will be development or dev if the environment is never specified with DOTNET_ENV.

    SetBasePath(String)

    Sets the base path for the .env files.

    SetCommentChar(Char)

    Sets the character that will define the beginning of a comment.

    SetDefaultEnvFileName(String)

    Sets the default name of an .env file.

    SetDelimiterKeyValuePair(Char)

    Sets the delimiter that separates an assignment of a value to a key.

    SetEncoding(String)

    Sets the encoding name of the .env files.

    SetEncoding(Encoding)

    Sets the encoding of the .env files.

    SetEnvironmentName(String)

    Sets the name of the environment.

    SetEnvironmentVariablesProvider(IEnvironmentVariablesProvider)

    Sets the environment variables provider. When this method is used, the environment variables are obtained from the custom provider.

    • Improve this Doc
    • View Source
    In This Article
    Back to top Copyright ©2021 DotEnv.Core