Register BOL services¶
Consumers call RegisterBolServices once during service configuration so that every page model, view component, and facade in the library can be resolved. BolRazorLayoutStartup calls it automatically.
| Field | Value |
|---|---|
| Operation ID | OP-01 |
| Trigger | Application startup calling RegisterBolServices |
| Inputs | IServiceCollection |
| Outputs | The same collection with BOL registrations added |
| Primary components | BolServiceExtensions.RegisterBolServices |
| Entry point | src/BolMiddleware/Extensions/BolMiddlewareExtensions.cs |
Steps¶
- Add ASP.NET Core session services with
AddSession(). - Register the four internal API client packages by chained calls: BOL Context, BOL Menu, Policy Header, and Policy Core clients.
- Register
IHttpContextAccessoras a singleton. - Register
ISecurityServiceas scoped, andIWebContextService,IMenuService, andIPolicyHeaderServiceas singletons. - Register
IBolContextApiClientas a singleton a second time; it repeats the registration made in step 2 and the last registration wins. - Register
IBolServicesContainerandICookieServiceas scoped andIContextCookieHelperas a singleton. - Return the collection for chaining.
Process flow¶
The following diagram visualizes this operation's control flow.
flowchart TD
Start([RegisterBolServices]) --> S1[AddSession]
S1 --> S2[Register four API clients]
S2 --> S3[Register accessor and facades]
S3 --> S4[Register duplicate Context client]
S4 --> S5["Register container, cookie service, helper"]
S5 --> EndOk([Return IServiceCollection])
Failure and edge-case behavior¶
UseSession()and a distributed cache are not configured here; a consumer without them fails at runtime when session is first used, unless the base startup supplies them**.- Singleton facades depend on API clients whose lifetimes are set inside the client packages; a lifetime capture risk is unknown**.
- The duplicate
IBolContextApiClientregistration is redundant and may hide a differently configured client from the client package.
Note: Statements marked with
**could not be confirmed; treat as unknown until verified.
Related documentation¶
- Index
- Overview
- Architecture
- Dependencies
- Configuration
- Operations and processes
- Business rules
- Security and authorization
- Service registration
- API reference
Sources¶
- src/BolMiddleware/Extensions/BolMiddlewareExtensions.cs
- src/BolMiddleware/BolRazorLayoutStartup.cs