The `INotificationService` interface defines the contract for sending notifications. This service provides a way to send notifications to various channels, such as email, SMS, or push notifications. It enables loose coupling between the application components and allows for easy addition or replacement of notification channels.
The `INotificationService` can be injected into a class to send notifications. The specific method called depends on the desired notification channel and data.
public class MyService
{
private readonly INotificationService _notificationService;
public MyService(INotificationService notificationService)
{
_notificationService = notificationService;
}
public void SendMessage(string message)
{
_notificationService.Send(new Notification { Message = message });
}
}
Send(Notification notification) - Sends a notification.