CodeMode.MX
0.1.0
dotnet add package CodeMode.MX --version 0.1.0
NuGet\Install-Package CodeMode.MX -Version 0.1.0
<PackageReference Include="CodeMode.MX" Version="0.1.0" />
<PackageVersion Include="CodeMode.MX" Version="0.1.0" />
<PackageReference Include="CodeMode.MX" />
paket add CodeMode.MX --version 0.1.0
#r "nuget: CodeMode.MX, 0.1.0"
#:package CodeMode.MX@0.1.0
#addin nuget:?package=CodeMode.MX&version=0.1.0
#tool nuget:?package=CodeMode.MX&version=0.1.0
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:
- A pipeline consists of a handler, optionally wrapped by one or more middleware.
- Handlers centralize the code for handling requests.
- 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.
- 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.
- 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 | Versions 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. |
-
.NETStandard 2.1
- Microsoft.Extensions.DependencyInjection (>= 8.0.0)
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 |