Eml.Mediator 2.2.0.2

There is a newer version of this package available.
See the version list below for details.
The owner has unlisted this package. This could mean that the package is deprecated, has security vulnerabilities or shouldn't be used anymore.
dotnet add package Eml.Mediator --version 2.2.0.2
NuGet\Install-Package Eml.Mediator -Version 2.2.0.2
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="Eml.Mediator" Version="2.2.0.2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Eml.Mediator --version 2.2.0.2
#r "nuget: Eml.Mediator, 2.2.0.2"
#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 Eml.Mediator as a Cake Addin
#addin nuget:?package=Eml.Mediator&version=2.2.0.2

// Install Eml.Mediator as a Cake Tool
#tool nuget:?package=Eml.Mediator&version=2.2.0.2

Eml.Mediator

A. Usage - Command

    [Test]
    public async Task Command_ShouldBeCalledOnce()
    {
        var command = new TestCommandAsync();			//<-Data

        await mediator.ExecuteAsync(command);           //<-Execute

        command.EngineInvocationCount.ShouldBe(1);
    }

1. Create a command class.

TestCommandAsync contains the needed data for the CommandEngine.

    public class TestCommandAsync : ICommandAsync
    {
        public int EngineInvocationCount { get; set; }

        public TestCommandAsync()
        {
            EngineInvocationCount = 0;
        }
    }

2. Create a command engine.

TestCommandEngine will be auto-discovered and executed by await command.ExecuteAsync();.

    [PartCreationPolicy(CreationPolicy.NonShared)]
    public class TestCommandEngine : ICommandAsyncEngine<TestCommandAsync>
    {
        public async Task ExecuteAsync(TestCommandAsync commandAsync)
        {
            await Task.Run(() => commandAsync.EngineInvocationCount++);
        }
    }

B. Usage - Request-Response

    [Test]
    public async Task Response_ShouldReturnCorrectValue()
    {
        var request = new TestRequestAsync(Guid.NewGuid());     //<-Data

        var response = await mediator.GetAsync(request);        //<-Execute

        response.ResponseToRequestId.ShouldBe(request.Id);      //<-Return Value
    }

1. Create a Request class.

TestRequestAsync contains the needed data for the RequestEngine.

    public class TestRequestAsync : IRequestAsync<TestRequestAsync, TestResponse>
    {
        public Guid Id { get; }                                 //<-Data

        public TestRequestAsync(Guid id)
        {
            Id = id;
        }
    }

2. Create a Response class.

TestResponse is the return value of RequestEngine.

    public class TestResponse : IResponse
    {
        public Guid ResponseToRequestId { get; }                //<-Return Value

        public TestResponse(Guid responseToRequestId)
        {
            ResponseToRequestId = responseToRequestId;
        }
    }

3. Create a Request engine.

TestRequestEngine will be auto-discovered and executed by await mediator.GetAsync(request);.

  • For NetFramework
    [PartCreationPolicy(CreationPolicy.NonShared)]
    public class TestRequestEngine : IRequestAsyncEngine<TestRequestAsync, TestResponse>
    {
        public async Task<TestResponse> GetAsync(TestRequestAsync request)  //<-Execute
        {
            return await Task.Run(() => new TestResponse(request.Id));
        }
    }
  • For NetCore2.2 (no need to place CreationPolicy.NonShared attribute)
    public class TestRequestEngine : IRequestAsyncEngine<TestRequestAsync, TestResponse>
    {
        public async Task<TestResponse> GetAsync(TestRequestAsync request)  //<-Execute
        {
            return await Task.Run(() => new TestResponse(request.Id));
        }
    }

That's it.

Check out EmlExtensions.vsix to automate the above process in one go.

alternate text is missing from this package README image

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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 is compatible.  net463 was computed.  net47 is compatible.  net471 is compatible.  net472 is compatible.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  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 (3)

Showing the top 3 NuGet packages that depend on Eml.Mediator:

Package Downloads
Eml.ControllerBase

ControllerBase for WebApi CRUD operations.

Eml.ControllerBase.Mvc

Base Classes for MVC CRUD operations and other useful utilities.

Eml.ControllerBase.Api.MySql

ControllerBase for WebApi with MySql.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
8.0.0 575 11/26/2023
7.1.2 678 9/3/2023
7.1.1 216 7/8/2023
7.1.0 193 7/1/2023
7.0.0 397 12/10/2022
6.0.3 533 8/27/2022
6.0.2 482 8/27/2022
6.0.0 1,731 1/19/2022
5.0.8 500 9/17/2021
5.0.7 550 3/16/2021
5.0.6 718 2/28/2021
5.0.0 676 1/16/2021
2.2.0.6 1,563 9/13/2020