EnvironmentInfo
EnvironmentInfo provides global metadata about the application's current runtime environment without requiring dependency injection.
Features
- Environment name:
EnvironmentInfo.Namepreserves the original ASP.NET Core environment name, including casing. - Environment type:
EnvironmentInfo.Typemaps the environment name to the framework'sEnvironmentTypeenum. - Development flag:
EnvironmentInfo.IsDev - Test flag:
EnvironmentInfo.IsTest - Automation flag:
EnvironmentInfo.IsAutomation - Production flag:
EnvironmentInfo.IsProd - Global access: static properties are available throughout the application.
Behavior
EnvironmentInfo initializes once when first accessed, reading the environment name from ASP.NET Core and mapping it to EnvironmentType.
Caveats
- If the environment name does not match a defined
EnvironmentType, the type defaults toDevelopment.