HaidaiTech.Notificator
2.1.0
dotnet add package HaidaiTech.Notificator --version 2.1.0
NuGet\Install-Package HaidaiTech.Notificator -Version 2.1.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="HaidaiTech.Notificator" Version="2.1.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add HaidaiTech.Notificator --version 2.1.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: HaidaiTech.Notificator, 2.1.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install HaidaiTech.Notificator as a Cake Addin
#addin nuget:?package=HaidaiTech.Notificator&version=2.1.0
// Install HaidaiTech.Notificator as a Cake Tool
#tool nuget:?package=HaidaiTech.Notificator&version=2.1.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Haidai Notificator
Haidai Notificator is a project developed by the Haidai team, implementing the Notification Pattern as described by Martin Fowler here.
Release Versions
- 2.1.0: Added Method Extension to inject NotificationContext to DI
Release Notes
Version 2.1.0
This release introduces an extension method that injects NotificationContext into the dependency injection container. Now you can do two things:
// Program.cs
using HaidaiTech.Notificator.Interfaces;
using HaidaiTech.Notificator.NotificationContextMessages;
using HaidaiTech.Notificator.NotificationContextPattern;
using HaidaiTech.Notificator.Extensions;
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddNotificationContextService();
//using your own notification context message
builder.Services.AddNotificationContextService<MyCustomNotificationContextMessage>();
//if you want to use your own DI, use this
builder.Services.AddScoped<INotificationContext<NotificationContextMessage>, NotificationContext<NotificationContextMessage>>();
//or
builder.Services.AddScoped<INotificationContext<MyCustomNotificationContextMessage>, NotificationContext<MyCustomNotificationContextMessage>>();
// Example using DDD pattern
public class AddNewCustomerCommandHandler
: IRequestHandler<AddNewCustomerCommand, string>
{
private readonly INotificationContext<NotificationContextMessage> _notificationContext;
public AddNewCustomerCommandHandler(INotificationContext<NotificationContextMessage> notificationContext)
{
_notificationContext = notificationContext;
}
public async Task<string> Handle(
AddNewCustomerCommand request,
CancellationToken cancellationToken
)
{
//this code is only AN EXAMPLE, read again : E-X-A-M-P-L-E !!!! XD~
if (request.Name is null)
_notificationContext.AddNotification(new NotificationContextMessage(
"The name is necessary",
NotificationContextErrorLevelHelper.ATTENTION,
NotificatorErrorCodesHelper.ERROR_CODE_027
));
if (request.Age < 18)
_notificationContext.AddNotification(new NotificationContextMessage(
"You must be 18",
NotificationContextErrorLevelHelper.CRITICAL,
NotificatorErrorCodesHelper.ERROR_CODE_072
));
if (_notificationContext.HasNotifications())
return await Task.Run(() =>
{
return "Problems";
});
else
return await Task.Run(() =>
{
return "Ok";
});
}
}
This project follow the TDD pattern. If you read the tests, you will understand the using of NotificationContext class.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.1 is compatible. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.1
- Microsoft.Extensions.DependencyInjection (>= 8.0.0)
-
net8.0
- Microsoft.Extensions.DependencyInjection (>= 8.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.