Register secure environment client¶
This operation registers the secure IEnvironmentClient implementation, enabling secure-setting retrieval gated by a per-assembly system hash. It underlies App startup configure services, Register for Windows service, and Console host bootstrap.
| Field | Value |
|---|---|
| Operation ID | OP-02 |
| Trigger | Application startup code calls RegisterSecureEnvironmentClient(Type type) on IServiceCollection. |
| Inputs | type — the caller's own type, used to resolve its containing assembly. |
| Outputs | Registers IEnvironmentClient → SecureEnvironmentClient and an ISystemHashService keyed on type's assembly. |
| Primary components | IServiceCollectionExtensions.RegisterSecureEnvironmentClient |
| Entry point | src/SAIF.NetCore.ServiceExtensions/SAIF.NetCore.ServiceExtensions/SAIF.NetCore.ServiceExtensions/IServiceCollectionExtensions.cs (L82–92) |
Steps¶
- Perform the same
AddHttpContextAccessor/ISystemWrapper/IHostResolver/IHttpJsonClientregistrations as Register environment client steps 1–3. - Register Singleton
IEnvironmentClient → SecureEnvironmentClient(BR-SE-03)
Origin:
SecureEnvironmentClient's secure-setting and caching behavior is implemented inGet secure settingandSecure setting cache(SAIF.NetCore.EnvironmentClient); this step only registers the type-based singleton descriptor — construction is deferred to first resolution ofIEnvironmentClient, not performed during registration. 3. Register a SingletonISystemHashServicefactory that constructsnew SystemHashService(Assembly.GetAssembly(type))(BR-SE-03) - Iftypeisnull:Assembly.GetAssemblythrowsArgumentNullException(inferred*).Origin:
SystemHashService's hash computation is implemented inCompute unsalted system hashandCompute salted system hash(SAIF.NetCore.SystemHash); this step only registers the factory delegate — the factory runs, andSystemHashServiceis constructed, at first resolution ofISystemHashService, not during registration.
Process flow¶
This diagram shows the one-time DI registration sequence performed when RegisterSecureEnvironmentClient(type) is called during service configuration; construction of SecureEnvironmentClient and SystemHashService is deferred to first resolution, not shown as occurring here.
flowchart TD
Start([RegisterSecureEnvironmentClient called]) --> S1[Register shared infra services]
S1 --> S2["Register IEnvironmentClient descriptor<br>as SecureEnvironmentClient"]
S2 --> S3["Register ISystemHashService factory delegate<br>(captures type, not yet invoked)"]
S3 --> EndOk(["Registration call returns; nothing constructed yet"])
EndOk -.->|First resolution of ISystemHashService| R1{type is null?}
R1 -->|Yes| EndErr(["Factory throws ArgumentNullException<br>from Assembly.GetAssembly(type)"])
R1 -->|No| R2["Factory constructs new SystemHashService<br>via Assembly.GetAssembly(type)"]
Failure and edge-case behavior¶
type == nullcausesAssembly.GetAssembly(type)to throwArgumentNullExceptionwhen the hash-service factory executes (inferred*).
Related documentation¶
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¶
src/SAIF.NetCore.ServiceExtensions/SAIF.NetCore.ServiceExtensions/SAIF.NetCore.ServiceExtensions/IServiceCollectionExtensions.cs