Levge.MediatR
2.3.0
dotnet add package Levge.MediatR --version 2.3.0
NuGet\Install-Package Levge.MediatR -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.MediatR" Version="2.3.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Levge.MediatR" Version="2.3.0" />
<PackageReference Include="Levge.MediatR" />
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.MediatR --version 2.3.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Levge.MediatR, 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.MediatR@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.MediatR&version=2.3.0
#tool nuget:?package=Levge.MediatR&version=2.3.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Levge.MediatR
MediatR tabanlı domain event dispatcher ve EF Core interceptor. IDomainEventDispatcher implementasyonu ve SaveChanges sonrası otomatik domain event dispatch altyapısı sağlar.
Kurulum
dotnet add package Levge.MediatR
İçerik
| Sınıf | Açıklama |
|---|---|
DomainEventNotification<T> |
DomainEvent'i MediatR INotification'a saran wrapper |
MediatRDomainEventDispatcher |
IDomainEventDispatcher'ın MediatR implementasyonu |
DomainEventDispatchInterceptor |
EF Core SaveChangesInterceptor — SavedChangesAsync sonrası event dispatch eder |
AddLevgeMediatR() |
MediatR'ı ve handler'ları DI'a kaydeder |
AddLevgeDomainEventInterceptors() |
DomainEventDispatchInterceptor'ı DbContext'e ekler |
Kullanım
1. DI Kaydı
// Infrastructure/DependencyInjection.cs
services.AddLevgeMediatR(Assembly.GetExecutingAssembly());
services.AddDbContext<AppDbContext>((sp, options) =>
{
options.UseSqlServer(connectionString);
options.AddLevgeDomainEventInterceptors(sp);
});
2. Domain Event Tanımla
// Domain/Events/OrderCreatedEvent.cs
public sealed record OrderCreatedEvent(long OrderId, decimal Total) : DomainEvent;
3. Entity'de Event Yayımla
public class Order : FullAuditableEntity
{
public static Order Create(long customerId, decimal total, long createdByUserId)
{
var order = new Order { ... };
order.RaiseDomainEvent(new OrderCreatedEvent(order.Id, total));
return order;
}
}
4. Handler Yaz
// Infrastructure/EventHandlers/OrderCreatedEventHandler.cs
public class OrderCreatedEventHandler : INotificationHandler<DomainEventNotification<OrderCreatedEvent>>
{
public async Task Handle(DomainEventNotification<OrderCreatedEvent> notification, CancellationToken cancellationToken)
{
var @event = notification.DomainEvent;
// işlemler...
}
}
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
- FluentValidation (>= 12.1.1)
- Levge.Domain (>= 2.3.0)
- Levge.Identity (>= 2.3.0)
- MediatR (>= 14.1.0)
- Microsoft.EntityFrameworkCore (>= 10.0.7)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.7)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.