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

# CustomEnvironmentService

`CustomEnvironmentService` is a host-specific concrete subclass of `EnvironmentServiceBase` for consumers that need to target a fixed, caller-specified host (rather than resolving it from `HttpContext`, the entry assembly, or a WCF `RequestContext`). The application host is supplied directly by the constructor caller, either as a raw host string or via the nested `CustomEnvironment` enum.

## Purpose
- Provide an `IEnvironmentService` implementation for hosting contexts where the environment host must be explicitly supplied rather than auto-detected.

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

## Public members
| Member | Signature | Purpose |
| --- | --- | --- |
| CustomEnvironmentService(host, applicationId, sections) | `public CustomEnvironmentService(string host, string applicationId, params string[] sections)` | Constructs the service with an explicit host string and loads the specified configuration sections. |
| CustomEnvironmentService(host, applicationId) | `public CustomEnvironmentService(string host, string applicationId)` | Constructs the service with an explicit host string. |
| CustomEnvironmentService(environment, applicationId, sections) | `public CustomEnvironmentService(CustomEnvironment environment, string applicationId, params string[] sections)` | Constructs the service from a `CustomEnvironment` enum value, resolving it to a known host, and loads the specified configuration sections. |
| CustomEnvironmentService(environment, applicationId) | `public CustomEnvironmentService(CustomEnvironment environment, string applicationId)` | Constructs the service from a `CustomEnvironment` enum value. |
| ApplicationHost | `public override string ApplicationHost { get; }` | Returns the host supplied at construction. |
| MachineName | `public override string MachineName { get; }` | Returns `Environment.MachineName`. |
| IsClientExternal | `public override bool IsClientExternal { get; }` | Always `false`. |
| IsClientInsideFirewall | `public override bool IsClientInsideFirewall { get; }` | Always `true`. |
| IsLocalMachine | `public override bool IsLocalMachine { get; }` | Always `true`. |
| IsWeb | `public override bool IsWeb { get; }` | Always `false`. |
| User | `public override IPrincipal User { get; }` | Returns `Thread.CurrentPrincipal`. |
| CustomEnvironment | `public enum CustomEnvironment { Dev, EntDev01, EntDev03, Test, EntTest01, EntTest02, EntTest03, EntTest04, QA, EntQA, EntSIT, EntUAT, Prod }` | Nested enum of known named environments that map to specific hard-coded host values (e.g. `Dev` → `entdev03`, `Prod` → `netprod`). |

## 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 |
| --- | --- | --- | --- |
| Configurations | `ConfigurationSettings Configurations { get; }` | The current in-memory cached configuration settings; triggers a refresh if not yet loaded. | `SAIF.Framework.Security.EnvironmentApi` — `EnvironmentServiceBase` |
| GetApplicationEnvironment | `ApplicationEnvironment GetApplicationEnvironment()` | Returns `Configurations.Environment`. | `SAIF.Framework.Security.EnvironmentApi` — `EnvironmentServiceBase` |
| GetApplicationTrack | `string GetApplicationTrack()` | Returns `Configurations.Track`. | `SAIF.Framework.Security.EnvironmentApi` — `EnvironmentServiceBase` |
| 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` |
| GetSecureConfigSetting | `string GetSecureConfigSetting(string configKey, string systemHashValue)` | Retrieves an encrypted configuration value. | `SAIF.Framework.Security.EnvironmentApi` — `EnvironmentServiceBase` |
| IsDeveloperMachine | `virtual bool IsDeveloperMachine { get; }` | Determines and memoizes developer-machine status (see [BR-005](../../business-rules.md#br-005-developer-machine-classification-requires-tag-number-host-and-ad-membership)). | `SAIF.Framework.Security.EnvironmentApi` — `EnvironmentServiceBase` |
| IsProduction | `bool IsProduction { get; }` | `true` when `GetApplicationEnvironment()` is `ApplicationEnvironment.Prod`. | `SAIF.Framework.Security.EnvironmentApi` — `EnvironmentServiceBase` |
| LoadSection | `ConfigurationSettings LoadSection(string section)` | Fetches and merges an entire named configuration section into the cache. | `SAIF.Framework.Security.EnvironmentApi` — `EnvironmentServiceBase` |

## Behavioral notes
- `GetRootApplicationFolder` (private) matches a known host prefix (`entdev`, `enttest`, `entqa`, `entsit`, `entuat`, `netdev`, `nettest`, `netqa`, `netprod`) from a file-system path but has no confirmed call site within this class*.
- The parameterless-style constructors (without a `sections` parameter) do not call the base class's section-loading constructor, so only global settings are loaded unless `sections` is explicitly supplied*.

## Constraints and usage notes
- Intended for hosting contexts (e.g. scheduled jobs, custom hosts) where the environment host cannot be auto-detected from `HttpContext`, the entry assembly, or a WCF `RequestContext`, and must instead be supplied directly by the caller.

> **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\CustomEnvironmentService.cs
- SAIF.Framework.Security.EnvironmentApi\Services.Common\EnvironmentServiceBase.cs
