Notices
Structr.Notices package is intended to help organize notification dispatching in application.
Installation
Notices package is available on NuGet.
dotnet add package Structr.NoticesSetup
Configure notice services:
services.AddNotices(typeof(Program).Assembly);AddNotices() extension method performs registration of notice publisher service INoticePublisher and notice handlers implementing INoticeHandler or inherited from NoticeHandler class.
assembliesToScan
params Assembly[]
List of assemblies to search notice handlers.
configureOptions
Action<NoticeServiceOptions>
Options to be used by notices handling service.
Additionally configure INoticePublisher service by specifying it's type and lifetime used NoticeServiceOptions.
NoticeServiceOptions properties:
PublisherServiceType
Type
Changes standard implementation of INoticePublisher to specified one. Default value is typeof(NoticePublisher).
PublisherServiceLifetime
ServiceLifetime
Specifies the lifetime of an INoticePublisher service. Default value is Transient.
Usage
The main difference from Structr.Operations package is that notice can handling by any of handlers while operation can handling by only one handler.
The basic usage is:
Create a notice class that inherits from INotice:
Create a notice handlers class that inherits from INoticeHandler or NoticeHandler:
The last step is to inject INoticePublisher service and use it:
Inherit from NoticeHandler class when you need synchronic-manner handler.
Last updated
Was this helpful?