Table of Contents

EnvironmentInfo

EnvironmentInfo provides global metadata about the application's current runtime environment without requiring dependency injection.

Features

  • Environment name: EnvironmentInfo.Name preserves the original ASP.NET Core environment name, including casing.
  • Environment type: EnvironmentInfo.Type maps the environment name to the framework's EnvironmentType enum.
  • 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 to Development.