NOF.Application 10.5.0

There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package NOF.Application --version 10.5.0
                    
NuGet\Install-Package NOF.Application -Version 10.5.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="NOF.Application" Version="10.5.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="NOF.Application" Version="10.5.0" />
                    
Directory.Packages.props
<PackageReference Include="NOF.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 NOF.Application --version 10.5.0
                    
#r "nuget: NOF.Application, 10.5.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 NOF.Application@10.5.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=NOF.Application&version=10.5.0
                    
Install as a Cake Addin
#tool nuget:?package=NOF.Application&version=10.5.0
                    
Install as a Cake Tool

NOF.Application

Application layer package for the NOF Framework.

Overview

Contains the application service abstractions used to implement NOF applications: RPC servers, request handlers, command handlers, notification handlers, state machines, mapping, and caching.

Commands and notifications are plain payload types. Handler discovery comes from the CommandHandler<T> and NotificationHandler<T> base classes rather than marker interfaces on the message types.

Key Abstractions

RPC Servers

RPC contracts are declared on IRpcService interfaces in the contract layer. Application implementations use RpcServer<TService>:

public partial class OrderService : RpcServer<IOrderService>;

public sealed class GetOrder : OrderService.GetOrder
{
    private readonly DbContext _dbContext;

    public GetOrder(DbContext dbContext)
    {
        _dbContext = dbContext;
    }

    public override async Task<Result<OrderDto>> HandleAsync(GetOrderRequest request, CancellationToken cancellationToken)
    {
        var order = await _dbContext.Set<Order>()
            .FirstOrDefaultAsync(entity => entity.Id == request.Id, cancellationToken);
        if (order is null)
        {
            return Result.Fail("404", "Order not found");
        }

        return Result.Success(new OrderDto(order.Id, order.Status));
    }
}

Command Handlers

public record SendEmailCommand(string To, string Subject, string Body);

public sealed class SendEmailHandler : CommandHandler<SendEmailCommand>
{
    public override Task HandleAsync(SendEmailCommand command, CancellationToken cancellationToken)
    {
        return Task.CompletedTask;
    }
}

Notification Handlers

public record OrderCreatedNotification(Guid OrderId);

public sealed class OrderCreatedHandler : NotificationHandler<OrderCreatedNotification>
{
    public override Task HandleAsync(OrderCreatedNotification notification, CancellationToken cancellationToken)
    {
        return Task.CompletedTask;
    }
}

State Machines

Declarative, event-driven state machines:

public sealed class OrderStateMachine : IStateMachineDefinition<OrderState>
{
    public void Build(IStateMachineBuilder<OrderState> builder)
    {
        builder.Correlate<OrderCreatedNotification>(n => n.OrderId.ToString());
        builder.Correlate<PaymentReceivedNotification>(n => n.OrderId.ToString());

        builder.StartWhen<OrderCreatedNotification>(OrderState.Pending)
            .SendCommandAsync(n => new StartProcessingCommand(n.OrderId));

        builder.On(OrderState.Pending)
            .When<PaymentReceivedNotification>()
            .TransitionTo(OrderState.Completed);
    }
}

Transactional Message Sending

Use ICommandSender and INotificationPublisher for both immediate and deferred dispatch:

_notificationPublisher.DeferPublish(new OrderCreatedNotification(order.Id));
_commandSender.DeferSend(new SendEmailCommand(order.Email, "Created", "Order created."));
await _dbContext.SaveChangesAsync(cancellationToken);

Object Mapping (IMapper)

NOF uses an explicit mapper with optional source-generated registrations via [Mappable]:

[Mappable<Order, OrderDto>]
[Mappable<Order, OrderSummary>(TwoWay = true)]
public static partial class Mappings;

The generator writes MapperRegistration entries into Registry.MapperRegistry. Those mappings become available once the assembly is added via AddApplicationPart(...). Convenience APIs can use the ambient mapper via source.Map, while explicit code can use source.MapWith(mapper).

Installation

dotnet add package NOF.Application

ICacheService also implements IDistributedCache, so standard distributed cache consumers can resolve either abstraction from NOF cache registrations.

License

Apache-2.0

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 (7)

Showing the top 5 NuGet packages that depend on NOF.Application:

Package Downloads
NOF.Infrastructure

Unified infrastructure package for the NOF Framework — abstractions, core pipeline, OpenTelemetry integration, and service wiring.

NOF.Test

Testing support for applications built with NOF, including lightweight test hosts, scoped execution helpers, and application-oriented integration testing utilities.

NOF.Infrastructure.Extension.Authorization.Jwt

JWT authorization extension for the NOF Framework — OIDC resource server, JWKS fetching, token validation, and identity resolution.

NOF.Infrastructure.RabbitMQ

RabbitMQ integration for the NOF Framework — message bus adapter for commands, events, and notifications using official RabbitMQ client.

NOF.Infrastructure.Memory

In-memory infrastructure implementation for the NOF Framework — cache and riders.

GitHub repositories

This package is not used by any popular GitHub repositories.