FlowX 1.1.0

dotnet add package FlowX --version 1.1.0                
NuGet\Install-Package FlowX -Version 1.1.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="FlowX" Version="1.1.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add FlowX --version 1.1.0                
#r "nuget: FlowX, 1.1.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.
// Install FlowX as a Cake Addin
#addin nuget:?package=FlowX&version=1.1.0

// Install FlowX as a Cake Tool
#tool nuget:?package=FlowX&version=1.1.0                

FlowX

FlowX is a modern library designed to simplify the creation and management of Request Flow patterns in .NET applications. This library is ideal for developers building enterprise-grade solutions who need a seamless approach to implementing CQRS (Command Query Responsibility Segregation) patterns.

Features

  • Fluent API for building Request Flows.
  • Error handling mechanisms with custom error definitions.

Getting Started

Prerequisites

Ensure you have the following installed:

  • .NET 8.0 or higher

Installation

To install the FlowX package, use the following NuGet command:

dotnet add package FlowX

Or via the NuGet Package Manager:

Install-Package FlowX

Usage

1. Register FlowX in the Dependency Injection Container

Add the FlowX to your service configuration to register OfX:


builder.Services.AddFlowX(cfg =>
{
    cfg.AddModelsFromNamespaceContaining<ITestAssemblyMarker>();
    cfg.AddHandlersFromNamespaceContaining<ITestAssemblyMarker>();
    cfg.AddSqlPipelines(c => c.OfType<SomeThingPipeline>(serviceLifetime));
});

Method descriptions

AddModelsFromNamespaceContaining<T>: Registers all models located in the namespace containing the specified assembly marker (T). Use this to automatically include models you’ve created in the same assembly.. AddHandlersFromNamespaceContaining<T> Registers all handlers from the namespace containing the specified assembly marker (T). This ensures any handlers you’ve implemented in that assembly are properly added. AddSqlPipelines Adds SQL pipelines for processing specific or generic requests. Customize the pipeline behavior using the provided configuration.!

Below is a sample implementation of a CreateSomeThingHandler using FlowX(FlowX.EntityFramework sample):


public sealed class CreateSomeThingHandler(
    ISqlRepository<SomeThing> sqlRepository,
    IMapper mapper,
    IUnitOfWork unitOfWork)
    : EfCommandOneVoidHandler<SomeThing, CreateSomeThingCommand>(sqlRepository, unitOfWork)
{
    protected override ICommandOneFlowBuilderVoid<SomeThing> BuildCommand(
        IStartOneCommandVoid<SomeThing> fromFlow, CreateSomeThingCommand command,
        CancellationToken cancellationToken)
        => fromFlow
            .CreateOne(mapper.Map<SomeThing>(command))
            .WithCondition(_ => None.Value)
            .WithErrorIfSaveChange(SomeErrorDetail());
}

Sample pipeline:

public sealed class SomeThingPipeline : ISqlPipelineBehavior<GetSomeThingQuery, OneOf<SomeThingResponse, Error>>
{
    public async Task<OneOf<SomeThingResponse, Error>> HandleAsync(RequestContext<GetSomeThingQuery> requestContext,
        Func<Task<OneOf<SomeThingResponse, Error>>> next)
    {
        Console.WriteLine("GetUserPipeline");
        var result = await next.Invoke();
        return result;
    }
}

How to invoke the request:

var sender = ServiceProvider.GetRequiredService<IFlowXSender>();
var userResult = await sender.ExecuteAsync(new GetUserQuery("1"));

Like the Mediator Pattern, you don't need to care about the handler and how it do. Just ExecuteAsync

Key Concepts

Request Flows

FlowX enables the creation of requests in a structured and intuitive way. Each flow defines a step-by-step process that ensures reliability and maintainability.

Error Handling

Errors in FlowX are predefined, enabling consistent error messaging across your application.

Contributing

We welcome contributions to FlowX! To contribute, please:

  1. Fork the repository.
  2. Create a new branch for your feature or bug fix.
  3. Submit a pull request with a detailed explanation of your changes.

License

FlowX is licensed under the MIT License. See LICENSE for more details.

Contact

For inquiries, reach out to FlowX.


Happy coding with FlowX!

Package Name Description .NET Version Document
FlowX FlowX core 8.0, 9.0 This Document
FlowX.EntityFrameworkCore This is the FlowX extension package using EntityFramework to fetch data 8.0, 9.0 ReadMe
Product Compatible and additional computed target framework versions.
.NET 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on FlowX:

Package Downloads
FlowX.EntityFrameworkCore

FlowX.EntityFrameworkCore, a high performance and convenience package for database, interactive with database using EF Core

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.1.0 84 1/3/2025
1.0.0 75 1/2/2025