---
title: WindowsEnvironmentService
summary: API reference for WindowsEnvironmentService.
status: draft
owner: <owner>
last_reviewed: 2026-07-23
library: SAIF.Framework.Security.EnvironmentApi
reference_type: package
---

# WindowsEnvironmentService

`WindowsEnvironmentService` is the host-specific `EnvironmentServiceBase` implementation for console applications and Windows services. It resolves the application host and track from the entry assembly and the Environment API's `/v2/tracks/{ApplicationId}/value` endpoint.

## Purpose
- Supply console/Windows-service-specific environment resolution, including host discovery from the running executable's file path and a fallback host list.

## Context
- Namespace: `SAIF.Framework.Security`
- Assembly/package: `SAIF.Framework.Security.EnvironmentApi`

## Public members
| Member | Signature | Purpose |
| --- | --- | --- |
| WindowsEnvironmentService(sections) | `public WindowsEnvironmentService(params string[] sections)` | Constructs the service, resolving `ApplicationId` from the entry assembly's full name. |
| ApplicationHost | `override string ApplicationHost { get; }` | Resolves the host by matching path segments of the command line or executing assembly location against the known hosts list (`InitHosts()`), falling back to a developer host (`entdev01`) then `Environment.MachineName`. |
| MachineName | `override string MachineName { get; }` | Returns `Environment.MachineName`. |
| IsClientExternal | `override bool IsClientExternal { get; }` | Always `false`. |
| IsClientInsideFirewall | `override bool IsClientInsideFirewall { get; }` | Always `true`. |
| IsLocalMachine | `override bool IsLocalMachine { get; }` | `true` when `GetApplicationEnvironment()` is `ApplicationEnvironment.Dev` *and* `IsDeveloperMachine` is true. |
| IsWeb | `override bool IsWeb { get; }` | Always `false`. |
| User | `override IPrincipal User { get; }` | Returns `Thread.CurrentPrincipal`. |

## Inherited public members

Members in this section are inherited from `EnvironmentServiceBase` in `SAIF.Framework.Security.EnvironmentApi`. They are available on this type through inheritance.

| Member | Signature | Purpose | Origin |
| --- | --- | --- | --- |
| GetConfigSetting | `string GetConfigSetting(string configKey)` | Retrieves a plain-text configuration value | `SAIF.Framework.Security.EnvironmentApi` — `EnvironmentServiceBase` |
| GetConfigSetting\<T\> | `T GetConfigSetting<T>(string configKey)` | Retrieves a typed configuration value | `SAIF.Framework.Security.EnvironmentApi` — `EnvironmentServiceBase` |
| GetApplicationEnvironment | `ApplicationEnvironment GetApplicationEnvironment()` | Returns the current deployment tier | `SAIF.Framework.Security.EnvironmentApi` — `EnvironmentServiceBase` |
| GetApplicationTrack | `string GetApplicationTrack()` | Returns the current application's deployment track | `SAIF.Framework.Security.EnvironmentApi` — `EnvironmentServiceBase` |
| IsDeveloperMachine | `virtual bool IsDeveloperMachine { get; }` | Determines developer-machine status | `SAIF.Framework.Security.EnvironmentApi` — `EnvironmentServiceBase` |
| Configurations | `ConfigurationSettings Configurations { get; }` | The current in-memory cached configuration settings | `SAIF.Framework.Security.EnvironmentApi` — `EnvironmentServiceBase` |

## Behavioral notes
- `InitHosts()` (private) fetches the known host list from `{EnvironmentApiUrl}/v2/tracks/{ApplicationId}/value`; on any exception, it falls back to a hard-coded host list (`entdev01,entdev03,enttest01,enttest02,enttest03,enttest04,entqa,entsit,entuat,netprod`).
- `GetRootApplicationFolder` (private) matches path segments of the running executable against the resolved hosts list to infer the deployed environment folder*.
- `IsLocalMachine` combines developer-machine detection with the `Dev` deployment tier, unlike other host implementations that determine locality from request loopback status.

## Constraints and usage notes
- Intended for console applications and Windows services where no `HttpContext`/WCF `RequestContext` is available.
- If the Environment API tracks endpoint is unreachable, host resolution silently falls back to the hard-coded host list rather than failing*.

> **Note:** Statements marked with * were inferred from code structure, naming conventions, or
> contextual evidence where direct confirmation was not available in source artifacts. Statements
> marked with ** could not be confirmed; treat as unknown until verified.

## Sources
- SAIF.Framework.Security.EnvironmentApi\Services.Common\WindowsEnvironmentService.cs
- SAIF.Framework.Security.EnvironmentApi\Services.Common\EnvironmentServiceBase.cs
