CodeMode.MX 0.1.0

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

Introduction

MX (Message X) is a message dispatcher modeled after the mediator pattern, a design pattern used for facilitating communication between components. It is intended for use in building APIs (Micro-services).

A mediator consumes a message object, builds an execution pipeline for that message, and runs the pipeline with the message as a parameter. This generates a response that is returned to the caller. MX decouples the execution process, ensuring the caller remains unaware of the specific implementation handling any given message.

Key features of MX include:

  1. A pipeline consists of a handler, optionally wrapped by one or more middleware.
  2. Handlers centralize the code for handling requests.
  3. Middleware allows for pre- and post-execution around the handler, enhancing flexibility.

MX is closely modeled after MediatR but with additional functionality and some exclusions based on utility.

  1. MediatR handles "Notifications" (Requests with no response) and "Streams" (Responses with no request), which are not included in MX. These concepts are handled by Request/Response in MX.
  2. Handlers and Middleware in MX are selected based on the request type and any inherited types, allowing broader applicability for middleware and more flexible handling of messages.

Getting Started

First install the MX Nuget Package. Then create your Request type:

public class MyRequest : IRequest<bool> { }

Then create your request handler:

public class MyRequestHandler : IRequestHandler<MyRequest, bool> {
    public async Task<bool> Handle(MyRequest request, CancellationToken cancellationToken) {
        // Handler logic here
        return false;
    }
}

Then register the handler with the DI Container:

services.AddMX();
services.AddMXHandler<MyRequestHandler>();

Then get the IMX instance from the service provider, and run the message.

// Getting the IMX instance
var imx = provider.GetService<IMX>();
// Running the message through its pipeline
var result = await imx.Run(new MyRequest() { }, default);
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  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 was computed.  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 was computed.  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 was computed.  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. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos 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.

Version Downloads Last Updated
0.1.0 344 12/9/2023