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
#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

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 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.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.1.0 109 2/10/2024
2.0.0 147 12/25/2023
1.3.1 116 8/27/2023
1.2.1 120 8/19/2023
1.1.1 102 8/19/2023
1.0.1 120 8/15/2023
1.0.0 116 8/10/2023