ZaminX.BuildingBlocks.Application 10.0.0-beta.1

This is a prerelease version of ZaminX.BuildingBlocks.Application.
dotnet add package ZaminX.BuildingBlocks.Application --version 10.0.0-beta.1
                    
NuGet\Install-Package ZaminX.BuildingBlocks.Application -Version 10.0.0-beta.1
                    
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="ZaminX.BuildingBlocks.Application" Version="10.0.0-beta.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ZaminX.BuildingBlocks.Application" Version="10.0.0-beta.1" />
                    
Directory.Packages.props
<PackageReference Include="ZaminX.BuildingBlocks.Application" />
                    
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 ZaminX.BuildingBlocks.Application --version 10.0.0-beta.1
                    
#r "nuget: ZaminX.BuildingBlocks.Application, 10.0.0-beta.1"
                    
#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 ZaminX.BuildingBlocks.Application@10.0.0-beta.1
                    
#: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=ZaminX.BuildingBlocks.Application&version=10.0.0-beta.1&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=ZaminX.BuildingBlocks.Application&version=10.0.0-beta.1&prerelease
                    
Install as a Cake Tool

ZaminX.BuildingBlocks.Application

معرفی

این پروژه مجموعه‌ای از primitiveهای لایه Application در ZaminX را فراهم می‌کند.

هدف این ماژول:

  • تعریف الگوی استاندارد برای Command / Query / Event
  • ارائه یک Mediator سبک و قابل توسعه
  • فراهم کردن pipeline behaviorها
  • ارائه Result pattern یکپارچه
  • پشتیبانی از معماری modular monolith

قابلیت‌ها

Messaging

  • ICommand
  • IQuery
  • IEvent

Handlers

  • ICommandHandler
  • IQueryHandler
  • IEventHandler

Mediator

  • IMediator
  • Send برای requestها
  • Publish برای eventها

Result Pattern

  • Result
  • Result<T>
  • پشتیبانی از چندین error

Pipeline Behaviors

  • اجرای behaviorها قبل/بعد از handler
  • پشتیبانی از ordering

Built-in Behaviors

  • RequestTelemetry
  • ExceptionToResult

نصب و استفاده

1. ثبت زیرساخت Application

services.AddZaminXApplication(options =>
{
    options.EnableRequestTelemetryBehavior = true;
    options.EnableExceptionToResultBehavior = true;
});

2. ثبت handlerها

services.AddZaminXApplicationHandlers(typeof(MyModuleMarker).Assembly);

در معماری modular monolith، هر ماژول باید handlerهای خودش را register کند.


3. استفاده از Mediator

var result = await mediator.Send(new CreateOrderCommand(...));
await mediator.Publish(new OrderCreatedEvent(...));

Custom Behavior

برای اضافه کردن behavior سفارشی:

services.AddZaminXApplication(options =>
{
    options.AddOpenBehavior(typeof(MyCustomBehavior<,>));
});

نکته مهم

  • نیاز به register دستی ندارد
  • به‌صورت خودکار در DI ثبت می‌شود
  • به‌صورت خودکار وارد pipeline می‌شود

Dependencyهای Behavior

اگر behavior شما dependency داشته باشد:

public class MyBehavior<TMessage, TResponse>
{
    public MyBehavior(IMyService service) { }
}

باید dependency را جدا register کنید:

services.AddScoped<IMyService, MyService>();

Pipeline Execution

ترتیب پیش‌فرض:

  1. RequestTelemetry
  2. Validation
  3. Custom Behaviors
  4. ExceptionToResult

ترتیب نهایی با Order تعیین می‌شود.


Validation

Validation در core وجود ندارد.

برای فعال‌سازی:

services.AddZaminXApplicationFluentValidation(options ⇒ { options.AddAssembly(typeof(ModuleMarker).Assembly); });

Modular Monolith

الگوی پیشنهادی:

services.AddZaminXApplication();

services.AddSalesModule();
services.AddIdentityModule();

و داخل هر ماژول:

services.AddZaminXApplicationHandlers(typeof(ModuleMarker).Assembly);

ASP.NET Core Integration

برای تبدیل Result به HTTP response:

از پروژه:

ZaminX.BuildingBlocks.Application.AspNetCore

استفاده کنید.


مستندات

برای جزئیات بیشتر:

  • mediator.md
  • result.md
  • commands.md
  • queries.md

خارج از محدوده این ماژول

  • message bus
  • distributed messaging
  • transaction management
  • caching
  • retry policies

جمع‌بندی

این ماژول یک لایه Application سبک، قابل توسعه و مناسب برای:

  • Clean Architecture
  • Modular Monolith
  • Microservices

فراهم می‌کند.

Product 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.

NuGet packages (3)

Showing the top 3 NuGet packages that depend on ZaminX.BuildingBlocks.Application:

Package Downloads
ZaminX.BuildingBlocks.Application.FluentValidation

Package Description

ZaminX.ApplicationPatterns.HandlerExecution

Package Description

ZaminX.BuildingBlocks.Application.AspNetCore

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
10.0.0-beta.1 746 4/12/2026