System Library Common Framework
Search Results for

    *.Benchmark*,*.Tests*,*.ApiTests*,*.BaseTest*,DelegateJsonConverter,CalleeCancelledRequestException,ClientResponse,ContentType,OutputCachePolicy
    Show / Hide Table of Contents Show / Hide Table of Contents
    NamespaceSystemLibrary.Common.Framework SystemLibrary.Common.Framework.Net.dll

    EnvironmentConfig with an option to pass your own Configuration class, along with an enum that defines all environment names.

    EnvironmentConfig<T, TEnvironmentNameEnum>

    public abstract class EnvironmentConfig<T, TEnvironmentNameEnum> : Config<T> where T : class where TEnvironmentNameEnum : struct, IComparable, IFormattable, IConvertible

    Inheritance
    object
    Config<T>
    EnvironmentConfig<T, TEnvironmentNameEnum>
    EnvironmentConfig
    Inherited Members
    Config<T>.Current
    Type Parameters
    Name Description
    T
    TEnvironmentNameEnum
    Examples
    Arguments
    X
    Generic types
    Name Description
    T
    TEnvironmentNameEnum

    Properties

    Returns the Environment Name as an Enum

    public TEnvironmentNameEnum EnvironmentName { get; }

    X
    Property Value
    Type Description
    TEnvironmentNameEnum

    Returns the environment name based on the ASPNETCORE_ENVIRONMENT variable passed during the startup of your application.

    This variable name is used for configuration transformations for all C# config classes that inherit from Config<>.

    Remarks
    X

    Changing the environment name requires a shell restart (e.g., iisreset).

    Transformation for the EnvironmentConfig class is run based on the ASPNETCORE_ENVIRONMENT passed. Additionally, a environmentConfig.someEnvName.json file may include a Name that differs from the environment name, in which case this Name in the transformed file will be returned instead.

    public string Name { get; set; }

    X

    Test Explorer

    if: mstest.runsettings contains 'ASPNETCORE_ENVIRONMENT' variable
        then: sets 'temp environment' as value
    
        if: 'temp environment' is set, but no transformation is found
            then: sets 'temp environment' as value from 'Configuration Mode' in Visual Studio
    
    else:
        then: sets 'temp environment' as value from 'Configuration Mode' in Visual Studio
    
    if: environmentConfig.json exists
        if transformation file exists for 'temp environment' 
            then: run transformation for environmentConfig.json
    
        if: environmentConfig.json contains 'name' property
            return: 'value'
    
    if: mstest.runsettings contains 'ASPNETCORE_ENVIRONMENT' variable
         return: 'value'
    
    if: ASPNETCORE_ENVIRONMENT exists in 'Environment Variables on Windows'
        return: 'value'
    
    return: "" as 'name', never null

    Console Application

    if: environmentConfig.json do not exists:
        if: mstest.runsettings contains 'ASPNETCORE_ENVIRONMENT' variable
            return: 'value'
    
        if: ASPNETCORE_ENVIRONMENT exists in 'Environment Variables on Windows'
            return: 'value'
    
    else if: 
        if: environmentConfig has transformation equal to 'configuration' pass in as argument
            then: run transformation
    
        if: environmentConfig has property 'name'
            return: 'value'
    
    return: "" as 'name', never null

    DOTNET TEST 'csproj' --configuration 'release|debug|etc..' command

    if: environmentConfig.json do not exists:
        if: mstest.runsettings contains 'ASPNETCORE_ENVIRONMENT' variable
            return: 'value'
    
    if: ASPNETCORE_ENVIRONMENT exists in 'Environment Variables on Windows'
        return: 'value'
    
    else if: 
        if: environmentConfig has transformation equal to 'configuration' pass in as argument
            then: run transformation
    
        if: environmentConfig has property 'name'
            return: 'value'
    
    return: "" as 'name', never null

    IISExpress

    if: launchSettings.json exists
        if: command "IISExpress" exists and contains environment variable 'ASPNETCORE_ENVIRONMENT'
            if: 'ASPNETCORE_ENVIRONMENT' exists
                if: environmentConfig.json exists
                    if: transformation file exists for 'value'
                    then: run transformation
    
                    if: environmentConfig contains 'name' property  
                    return: 'value'
    
                return: 'value'
    
    if: 'ASPNETCORE_ENVIRONMENT' exists in web.config
        if: environmentConfig.json exists
            if: transformation file exists for 'value'
            then: run transformation
    
            if: environmentConfig contains 'name' property
                return: 'value'
    
        return: 'value'
    
    if: 'ASPNETCORE_ENVIRONMENT' exists as a 'environment variable' in Windows
        if: environmentConfig.json exists
            if: transformation file exists for 'value'
            then: run transformation
    
            if: environmentConfig contains 'name' property
                return: 'value'
    
        return: 'value'
    
    if: launchSettings.json exists
        if: "iisSettings" contains "iisExpress" and contains environment variable 'ASPNETCORE_ENVIRONMENT'
            if: environmentConfig.json exists
                if: transformation file exist for 'value'
                then: run transformation
    
                if: environmentConfig.json contains 'name' property
                    return: 'value'
    
            return: 'value'
    
        if: "iisSettings" contains environment variable 'ASPNETCORE_ENVIRONMENT'
            if: environmentConfig.json exists
                if: transformation file exists for 'value'
                then: run transformation
    
                if: environmentConfig.json contains 'name' property
                return: 'value'
    
            return: 'value'
    
        if: command "IIS" exists and contains environment variable 'ASPNETCORE_ENVIRONMENT'
            if: environmentConfig.json exists
                if: transformation file exists for 'value'
                then: run transformation
    
                if: environmentConfig.json contains 'name' property
                    return: 'value'
    
    if: environmentConfig.json exists
        if: environmentConfig.json contains 'name' property
            return: 'value'
    
    return: "" as 'name', never null

    IIS

    if: 'ASPNETCORE_ENVIRONMENT' exists in web.config
        if: environmentConfig.json exists
            if: transformation file exists 'value' 
            then: run transformation 
    
            if: environmentConfig.json contains 'name' property
                return: 'value'
    
        return: 'value'
    
    if: launchSettings.json exists
        if: "iisSettings" contains "iisExpress"
            if: "iisExpress" contains 'environmentVariables'
                if: 'ASPNETCORE_ENVIRONMENT' exists
                    if: environmentConfig.json exists
                        if: transformation file exist for 'value'
                        then: run transformation
    
                        if: environmentConfig.json contains 'name' property
                            return: 'value'
    
        if: "iisSettings" contains 'environmentVariables'
            if: 'ASPNETCORE_ENVIRONMENT' exists
                if: environmentConfig.json exists
                    if: transformation file exist for 'value'
                    then: run transformation
    
                    if: environmentConfig.json contains 'name' property
                        return: 'value'
    
        if: "profiles" exists
            if: command "IIS" exists and contains 'environmentVariables'
                if: 'ASPNETCORE_ENVIRONMENT' exists
                    if: environmentConfig.json exists
                        if: trnasformation file exists for 'value'
                        then: transformation is ran
    
                        if: environmentConfig.json contains 'name' property
                            return: 'value'
    
                    return: 'value'
    
    return: "" as 'name', never null
    X
    Property Value
    Type Description
    string

    Extension Methods

    ObjectExtensions.Json(object, bool)
    ObjectExtensions.Json(object, JsonSerializerOptions, bool, params JsonConverter[])
    ObjectExtensions.Json(object, params JsonConverter[])
    ObjectExtensions.Xml(object)

    }

    In This Article
    Package: nuget
    Source: github
    Website: System Library Common Framework