Tooark.Notifications
4.7.1
dotnet add package Tooark.Notifications --version 4.7.1
NuGet\Install-Package Tooark.Notifications -Version 4.7.1
<PackageReference Include="Tooark.Notifications" Version="4.7.1" />
<PackageVersion Include="Tooark.Notifications" Version="4.7.1" />
<PackageReference Include="Tooark.Notifications" />
paket add Tooark.Notifications --version 4.7.1
#r "nuget: Tooark.Notifications, 4.7.1"
#:package Tooark.Notifications@4.7.1
#addin nuget:?package=Tooark.Notifications&version=4.7.1
#tool nuget:?package=Tooark.Notifications&version=4.7.1
Tooark.Notifications
Library for creating and managing notifications and alerts, easing communication and monitoring in .NET projects.
π Docs: Tooark.Notifications on the site Β· All packages Β· API reference
π Languages: πΊπΈ English (this file) Β· π§π· PortuguΓͺs
π Contents
π§ Installation
dotnet add package Tooark.Notifications
The package has no configuration. Notification is used through inheritance, in classes that accumulate
the result of several checks β such as the Tooark value objects and entities β, and the mutators are
protected: the object itself accumulates the notification, not whoever consumes it.
Messages are stored as a key, not as final text. Translation is done by the layer that builds the
response, such as the ResponseDto of Tooark.Dtos.
π§± Classes
The available classes are:
1. Notification Item
Purpose: Represents the structure of a notification item with message, key and error code. The values are normalized on construction and the instance is read-only.
Properties:
Message: The notification message.Key: The notification key.Code: The notification error code.
Methods:
NotificationItem(string? message): Creates a new instance with theUnknownkey and theT.ERRcode.NotificationItem(string? message, string? key): Creates a new instance with the given key and theT.ERRcode.NotificationItem(string? message, string? key, string? code): Creates a new instance with the given key and code.
The three parameters accept a missing value because the constructor already handled it: a blank message
becomes Notifications.MessageNullEmpty, a blank key becomes Unknown and a blank code becomes T.ERR.
The signature declared non-nullable while the body checked for null β whoever passed a string? got a
compiler warning for a path that always worked.
ToString(): Returns the notification message.string: Implicitly converts aNotificationIteminstance to a string, returning the message. A null instance returns an empty string.NotificationItem: Implicitly converts a string to aNotificationIteminstance, with theUnknownkey and theT.ERRcode.
Value normalization:
| Parameter | Null, empty or blank | Other values |
|---|---|---|
message |
Notifications.MessageNullEmpty |
Leading and trailing whitespace removed |
key |
Unknown |
All whitespace removed, including tabs and line breaks |
code |
T.ERR |
Leading and trailing whitespace removed |
2. Notification
Purpose:
Abstract class that manages the notification list of the object inheriting it. It is the base of ValueObject, BaseEntity and Validation.
Creating and clearing notifications is protected: only the object itself decides what it notifies. Aggregating existing notifications is public, allowing the validation result of other objects to be composed.
Properties:
Notifications: Returns the read-only list of notifications.IsValid: Returns true if the notification list is empty.Count: Returns the number of notifications.Codes: Returns the list of error codes of the notifications.Keys: Returns the list of keys of the notifications.Messages: Returns the list of messages of the notifications.
Public methods:
AddNotifications(Notification notification): Adds the notifications of another notification to the notification list.AddNotifications(params Notification[] notifications): Adds the notifications of a collection of notifications to the notification list.
Protected methods:
AddNotification(NotificationItem notification): Adds a notification item to the notification list.AddNotification(Type property, string message): Adds a notification item using the type name as key.AddNotification(Type property, string message, string code): Adds a notification item using the type name as key, with an error code.AddNotification(string message, string key): Adds a notification item with message and key.AddNotification(string message, string key, string code): Adds a notification item with message, key and error code.AddNotifications(ICollection<NotificationItem> notifications): Adds a collection of notification items to the notification list.Clear(): Clears the notification list.
Null handling:
| Situation | Behavior |
|---|---|
Null argument in AddNotification or AddNotifications |
Adds the Notifications.NotificationNull notification |
| Null item inside a collection | Ignored, without changing the list |
Adding the instance itself in AddNotifications |
No effect, the list is not changed |
3. Error Messages
Purpose:
Static class NotificationErrorMessages with the messages generated by the library itself. They are translation keys, not final texts.
| Constant | Value | When it occurs |
|---|---|---|
MessageIsNullOrEmpty |
Notifications.MessageNullEmpty |
Null, empty or whitespace-only message |
NotificationIsNull |
Notifications.NotificationNull |
Notification or collection received as argument is null |
π Usage Examples
Notification Item
// Message, with the 'Unknown' key and the 'T.ERR' code
var notification1 = new NotificationItem("Example message");
// Message and key, with the 'T.ERR' code
var notification2 = new NotificationItem("Example message", "ExampleKey");
// Message, key and code
var notification3 = new NotificationItem("Example message", "ExampleKey", "XPTO1");
// The key has its whitespace removed
var notification4 = new NotificationItem("Example message", "Example Key");
var key = notification4.Key; // "ExampleKey"
Notification
// Adding notifications is protected: only the object itself notifies its errors
public class MyNotification : Notification
{
public void NotifyError(string message)
{
AddNotification(message, "Error", "XPTO1");
}
}
var myNotification = new MyNotification();
myNotification.NotifyError("An error occurred.");
var isValid = myNotification.IsValid; // False
var count = myNotification.Count; // 1
var codes = myNotification.Codes; // ["XPTO1"]
var keys = myNotification.Keys; // ["Error"]
var messages = myNotification.Messages; // ["An error occurred."]
var notifications = myNotification.Notifications; // [NotificationItem { Message = "An error occurred.", Key = "Error", Code = "XPTO1" }]
// Aggregation is public: existing notifications can be composed from outside the object
public class MyValidation : Notification
{ }
var validation = new MyValidation();
validation.AddNotifications(myNotification, myOtherNotification);
π€ Contributing
Contributions are welcome! Start with CONTRIBUTING.md β it covers the development workflow, the coding and commit conventions and the pull request checklist. Bugs and feature requests go through the issue templates of the Tooark repository.
By participating you agree to the Code of Conduct.
π Help & Security
- β Questions, bugs, feature ideas β see SUPPORT.md for the right channel
- π Security vulnerabilities β do not open a public issue; follow SECURITY.md
π Support
If Tooark helps your projects, consider supporting its development:
- π GitHub Sponsors
- β Ko-fi
Every contribution helps keep the project maintained and improving. Thank you! π
π License
This project is licensed under the BSD 3-Clause License.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | 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. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- No dependencies.
-
net8.0
- No dependencies.
NuGet packages (6)
Showing the top 5 NuGet packages that depend on Tooark.Notifications:
| Package | Downloads |
|---|---|
|
Tooark.Validations
Package for managing validations and standards for .NET applications. |
|
|
Tooark.Exceptions
Package for creating exceptions for .NET applications. |
|
|
Tooark.ValueObjects
Package for managing predefined and validated Value Objects for .NET applications. |
|
|
Tooark.Entities
Package for managing base entities in .NET applications. |
|
|
Tooark.Dtos
Package for managing base DTOs in .NET applications. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 4.7.1 | 0 | 10/17/2026 |
| 4.7.0 | 619 | 9/30/2026 |
| 4.6.0 | 350 | 9/29/2026 |
| 4.5.0 | 337 | 9/29/2026 |
| 4.4.0 | 331 | 9/28/2026 |
| 4.3.0 | 344 | 9/26/2026 |
| 4.2.1 | 339 | 9/25/2026 |
| 4.2.0 | 360 | 9/20/2026 |
| 4.1.0 | 322 | 9/18/2026 |
| 4.0.1 | 385 | 8/25/2026 |
| 4.0.0 | 396 | 8/25/2026 |
| 3.3.6 | 296 | 9/18/2026 |
| 3.3.5 | 323 | 8/25/2026 |
| 3.3.4 | 493 | 8/12/2026 |
| 3.3.3 | 594 | 7/27/2026 |
| 3.3.2 | 615 | 6/11/2026 |
| 3.3.1 | 379 | 6/6/2026 |
| 2.3.5 | 237 | 9/18/2026 |
| 2.3.4 | 283 | 8/25/2026 |
| 2.3.3 | 300 | 7/27/2026 |