Levge.Notification
2.3.0
dotnet add package Levge.Notification --version 2.3.0
NuGet\Install-Package Levge.Notification -Version 2.3.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="Levge.Notification" Version="2.3.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Levge.Notification" Version="2.3.0" />
<PackageReference Include="Levge.Notification" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Levge.Notification --version 2.3.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Levge.Notification, 2.3.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.
#:package Levge.Notification@2.3.0
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Levge.Notification&version=2.3.0
#tool nuget:?package=Levge.Notification&version=2.3.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Levge.Notification
Email, push ve anlık bildirim altyapısı. SMTP ve SendGrid desteği, RazorLight tabanlı HTML template render motoru ve genişletilebilir INotificationService soyutlaması. İleride Firebase push notification, SignalR gibi kanallar eklenebilir.
Kurulum
dotnet add package Levge.Notification
İçerik
| Sınıf / Interface | Açıklama |
|---|---|
INotificationService |
Üst seviye bildirim sözleşmesi (SendEmailAsync) |
IEmailSender |
Email gönderme alt seviye sözleşmesi |
EmailMessage |
Email mesaj DTO (To, Subject, TemplateName, Model) |
SmtpEmailSender |
MailKit tabanlı SMTP implementasyonu |
SendGridEmailSender |
SendGrid HTTP API implementasyonu |
RazorTemplateRenderer |
RazorLight ile .cshtml template render motoru |
EmailConfig |
SMTP + SendGrid konfigürasyon sınıfları |
WelcomeEmailModel |
WelcomeEmail.cshtml için view model |
ForgotPasswordModel |
ForgotPassword.cshtml için view model |
Kullanım
DI Kaydı
services.AddLevgeNotification(configuration);
appsettings.json:
{
"Email": {
"Provider": "Smtp",
"Smtp": {
"Host": "localhost",
"Port": 1025,
"From": "noreply@example.com",
"FromName": "MyApp"
}
}
}
Provider değerini "SendGrid" yaparak SendGrid'e geçebilirsiniz:
{
"Email": {
"Provider": "SendGrid",
"SendGrid": {
"ApiKey": "SG.xxx",
"From": "noreply@example.com",
"FromName": "MyApp"
}
}
}
Email Gönderme
public class UserRegisteredEventHandler : INotificationHandler<DomainEventNotification<UserRegisteredEvent>>
{
private readonly INotificationService _notifications;
public UserRegisteredEventHandler(INotificationService notifications)
{
_notifications = notifications;
}
public async Task Handle(DomainEventNotification<UserRegisteredEvent> notification, CancellationToken cancellationToken)
{
var evt = notification.Event;
await _notifications.SendEmailAsync(new EmailMessage
{
To = evt.Email,
ToName = evt.FirstName,
Subject = $"Welcome to {evt.TenantName}!",
TemplateName = "WelcomeEmail",
Model = new WelcomeEmailModel
{
FirstName = evt.FirstName,
Email = evt.Email,
TenantName = evt.TenantName
}
}, cancellationToken);
}
}
Özel Template Ekleme
Email/Templates/klasörüneMyEmail.cshtmlekle@modeldirektifinde kendi model sınıfını kullanTemplateName = "MyEmail"ile çağır
Lisans
MIT © Serdar ÖZKAN
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | 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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net10.0
- MailKit (>= 4.16.0)
- Microsoft.Extensions.Caching.Memory (>= 10.0.7)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.7)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.7)
- Microsoft.Extensions.Options (>= 10.0.7)
- RazorLight (>= 2.3.1)
- SendGrid (>= 9.29.3)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.