Eml.Mediator
2.2.0.2
See the version list below for details.
dotnet add package Eml.Mediator --version 2.2.0.2
NuGet\Install-Package Eml.Mediator -Version 2.2.0.2
<PackageReference Include="Eml.Mediator" Version="2.2.0.2" />
paket add Eml.Mediator --version 2.2.0.2
#r "nuget: Eml.Mediator, 2.2.0.2"
// 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.
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. |
.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. |
-
.NETFramework 4.6.2
- Eml.ClassFactory.Contracts (>= 2.2.0)
-
.NETFramework 4.7
- Eml.ClassFactory.Contracts (>= 2.2.0)
-
.NETFramework 4.7.1
- Eml.ClassFactory.Contracts (>= 2.2.0)
-
.NETFramework 4.7.2
- Eml.ClassFactory.Contracts (>= 2.2.0)
-
.NETStandard 2.0
- Eml.ClassFactory.Contracts (>= 2.2.0)
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.