Notie 1.0.2

There is a newer version of this package available.
See the version list below for details.
dotnet add package Notie --version 1.0.2                
NuGet\Install-Package Notie -Version 1.0.2                
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="Notie" Version="1.0.2" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Notie --version 1.0.2                
#r "nuget: Notie, 1.0.2"                
#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 Notie as a Cake Addin
#addin nuget:?package=Notie&version=1.0.2

// Install Notie as a Cake Tool
#tool nuget:?package=Notie&version=1.0.2                

✌ Hello!

Notie is a simple way to implement the Notification Pattern to notify your validations. A difference is that it is multi-purpose, so you can use it for notifications in any class or layer you want. Do what you want! 😄

🛠 Install

Use the installation means below.

CLI (Linux/Windows/Mac)

To install via the command line (CLI), just run the following command in your project folder:

  dotnet add package Notie
NuGet packages managers (Windows/Mac/Linux)

Just search for "Notie" in your Visual Studio/Rider and click on add package.

💻 Usage

Notie is intuitive and you can use the documentation provided by the code to help you, but I will also leave examples here.

Quick Examples

You can use it in several ways, but here is an example of what it is like to save your notifications:

using Notie;

// your validation here...

var notification = new Notification(key: "any_key", message: "any_message");
var notificator = new Notificator();

notificator.AddNotification(notification);

if (_sut.HasNotifications)
{
  // Handle...
}

You can even receive a list of notifications via the AddNotifications method. If notifications already exist in the notifier object, they will be merged by default. See example:

using Notie;

// your validation here...

List<Notification> notifications = new()
{
  new("any_key", "any_message"),
  new("other_key", "other_message")
};

var notificator = new Notificator();

notificator.AddNotifications(notifications);

if (_sut.HasNotifications)
{
  // Handle...
}

if you want to overwrite previous notifications, just set the overwrite parameter to true, as shown below.

using Notie;

// your validation here...
var notificator = new Notificator();
var notification = new Notification(key: "any_key", message: "any_message");
notificator.AddNotification(notification);

List<Notification> notifications = new()
{
  new("any_key", "any_message"),
  new("other_key", "other_message")
};

var notificator = new Notificator();

notificator.AddNotifications(notifications, true);

if (_sut.HasNotifications)
{
  // Handle...
}

if you want to clear all notifications you can do so using the Clear method.

Using with FluentValidation

You can also receive notifications from FluentValidation through the AddNotificationsByFluent method:

using Notie;

Entity entity = new Entity();
EntityValidator validator = new EntityValidator();
ValidationResult result = validator.Validate(entity);

var notificator = new Notificator();
notificator.AddNotificationsByFluent(result);

if (_sut.HasNotifications)
{
  // Handle...
}
Defining notification types

Each notifier can be in a different context, and for that we can define types for it through the NotificationType property. You can have notifications from repository, validation or any other service you need, so you can separate the notifications from each context and understand which part of the application is bringing the notifications. initial type of NotificationType is "Default". See example below:

using Notie;

// In the repository

var notificator = new Notificator();
notificator.SetNotificationType(new("Repository"));

// In the Domain

var notificator = new Notificator();
notificator.SetNotificationType(new("Validation"));

// In the user service

var notificator = new Notificator();
notificator.SetNotificationType(new("Service"));

This documentation will be increased as the project progresses, but issues can open, which I will answer as quickly as I can, I am happy with your comment. 😄

👋 See my Github!

Product Compatible and additional computed target framework versions.
.NET net5.0 is compatible.  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 was computed.  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. 
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.2.1 225 12/30/2023
2.2.0 121 12/30/2023
2.1.0 415 9/23/2021
2.0.2 365 8/25/2021
2.0.1 389 8/19/2021
2.0.0 379 7/18/2021
1.0.2 519 3/27/2021