ApexSoft.MediatR 1.0.6

dotnet add package ApexSoft.MediatR --version 1.0.6
                    
NuGet\Install-Package ApexSoft.MediatR -Version 1.0.6
                    
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="ApexSoft.MediatR" Version="1.0.6" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ApexSoft.MediatR" Version="1.0.6" />
                    
Directory.Packages.props
<PackageReference Include="ApexSoft.MediatR" />
                    
Project file
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 ApexSoft.MediatR --version 1.0.6
                    
#r "nuget: ApexSoft.MediatR, 1.0.6"
                    
#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 ApexSoft.MediatR@1.0.6
                    
#: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=ApexSoft.MediatR&version=1.0.6
                    
Install as a Cake Addin
#tool nuget:?package=ApexSoft.MediatR&version=1.0.6
                    
Install as a Cake Tool

ApexSoft.MediatR

ApexSoft.MediatR, .NET projelerinizde CQRS (Command Query Responsibility Segregation) desenini uygulamanızı sağlayan, hafif ve yüksek performanslı bir Mediator kütüphanesidir. Bu kütüphane, özellikle .NET Framework 4.8 gibi legacy sürümlerden .NET 9.0 gibi modern sürümlere kadar geniş bir yelpazede çalışan projeler için MediatR kütüphanesine alternatif olarak geliştirilmiştir.

🚀 Özellikler Hafif ve Hızlı: Gereksiz bağımlılıklardan arındırılmış saf CQRS yapısı.

Multi-Targeting: .NET Framework 4.8, 6.0, 7.0, 8.0 ve 9.0 sürümleriyle tam uyumludur.

Kolay Entegrasyon: IServiceCollection üzerinden tek satırla kayıt imkanı sunar.

Modern C# Desteği: Primary Constructors ve modern syntax özelliklerini destekler.

🛠 Kurulum Projenizde bağımlılıkların yönetildiği kısımda (örneğin ApplicationRegistration sınıfı) aşağıdaki tanımlamayı yaparak tüm Handler yapılarını otomatik olarak kaydedebilirsiniz:

C# public static class ApplicationRegistration { public static void AddApplicationServices(this IServiceCollection services) { // Belirtilen Assembly içindeki tüm IRequestHandler yapılarını tarar ve kaydeder. services.AddMediator(typeof(ApplicationRegistration).Assembly); } }

📖 Örnek Kullanım

  1. Query ve Handler Tanımlama İş mantığınızı Query ve Handler olarak tek bir dosyada organize ederek kod okunabilirliğini artırabilirsiniz:

C# public class GetAllDriverQuery : IRequest<ServiceResponse<IEnumerable<DriverDto>>> { public QueryOptions QueryOptions { get; set; }

public class GetAllDriverQueryHandler : IRequestHandler<GetAllDriverQuery, ServiceResponse<IEnumerable<DriverDto>>>
{
    private readonly IDriverRepository _driverRepository;
    private readonly IMapper _mapper;

    public GetAllDriverQueryHandler(IDriverRepository driverRepository, IMapper mapper)
    {
        _driverRepository = driverRepository;
        _mapper = mapper;
    }

    public async Task<ServiceResponse<IEnumerable<DriverDto>>> Handle(GetAllDriverQuery request, CancellationToken cancellationToken)
    {
        var driverEntities = await _driverRepository.GetAllAsync(request.QueryOptions);
        var driverDtos = _mapper.Map<List<DriverDto>>(driverEntities);
        
        return new ServiceResponse<IEnumerable<DriverDto>>(driverDtos, 200, "Success");
    }
}

}

  1. Controller İçinde Kullanım Handler'ı tetiklemek için ISender arayüzünü enjekte etmeniz yeterlidir:

C# public class DriverController : ControllerBase { private readonly ISender _sender;

public DriverController(ISender sender)
{
    _sender = sender;
}

[HttpGet("getall")]
public async Task<IActionResult> GetAllDriversAsync(QueryOptions options)
{
    var query = new GetAllDriverQuery() { QueryOptions = options };
    var result = await _sender.Send(query);
    
    return Ok(result);
}

}

🏗 Mimari Yakıt Bu kütüphane; Onion Architecture veya Clean Architecture prensiplerine uygun olarak, komut ve sorgu işlemlerini birbirinden ayırarak yönetmenize olanak tanır.

Geliştirici: Seyfullah Tanrıverdi

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  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 is compatible.  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 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 is compatible.  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 was computed.  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.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.