Component: Smrt.Notifications¶
Canonical source:
SmrtApps/src/Smrt.Notifications/README.md(mirrored below)
Smrt.Notifications¶
Public surface / entry points¶
NotificationrecordINotificationServiceNotificationService
Dependencies and integrations¶
- Dependency-free notification bus used by UI hosts and background components.
Configuration and operational data¶
- No persistent config/state is owned by this library.
Observability and diagnostics¶
- Callers should log notification intent/actions via
SmrtHub.Loggingwhen troubleshooting. - Do not log payload verbatim if it contains user text.
Support Bundle¶
- Not applicable directly (library); collect host application logs via Support Bundle.
Related docs¶
- HubWindow: SmrtApps/CSApps/HubWindow/README.md
Overview & Responsibilities¶
- Provides a lightweight, in-process notification bus that decouples publishers from UI surfaces (HubWindow toasts, tray popups, etc.).
- Keeps the payload immutable so subscribers can safely project to multiple UX channels.
- Designed to be dependency free; consumers wire logging and configuration using the shared
SmrtHub.LoggingandSmrt.Configbuilding blocks when needed.
Key APIs¶
Notificationrecord — immutable payload with requiredTitle, severityNotificationLevel, optionalMessage,IconKey, andWhentimestamp.INotificationService— interface withNotificationPublishedevent andPublishmethod for broadcasting notifications.NotificationService— default implementation that raises the event synchronously on the publishing thread.
Publishing Flow¶
- Consumers construct a
Notification(ensure titles are localized prior to publishing). - Call
INotificationService.Publish. Implementations may be injected via DI or resolved from the shell bootstrap. - Subscribers (e.g., HubWindow view models) handle
NotificationPublishedto present the message or enqueue it for batched display. - Callers should log notification intent/actions via
SmrtHub.Loggingwhen troubleshooting, but never log the payload verbatim if it contains user text.
Threading & Reliability Notes¶
NotificationServiceraises events synchronously; callers should consider offloading long-running UI work onto dispatcher contexts.- Subscribers must handle exceptions internally. Throwing from an event handler will bubble to the publisher.
- For background components, wrap
Publishwith retry/backoff logic when the consumer channel can momentarily reject updates.
Testing & Validation¶
- Unit-test publishers by substituting
INotificationServicewith a test double and asserting the published payload. - For UI subscribers, validate that notifications published during automated flows render correctly and honor severity styling.
- Contract tests should ensure the DI container wires a single shared instance when using the default implementation.
Directory Map¶
Notification.cs— immutable record defining the payload.NotificationService.cs— default implementation raising events.INotificationService.cs&NotificationLevel.cs— contract and severity enum.Smrt.Notifications.csproj— class library project (net8.0, RIDwin-x64).