Skip to content

Commit

Permalink
Working on mediator article
Browse files Browse the repository at this point in the history
  • Loading branch information
garywoodfine committed May 10, 2021
1 parent 188b68e commit 10c48ea
Show file tree
Hide file tree
Showing 11 changed files with 17 additions and 252 deletions.
6 changes: 4 additions & 2 deletions Mediator/README.md
Expand Up @@ -19,7 +19,7 @@ A drawback of the Mediator pattern is that without a proper design the Mediator
Fortunately, in C# Jimmy Bogard, of [Automapper](https://github.com/AutoMapper/AutoMapper) fame has also developed [MediatR - Simple mediator implementation in .NET](https://github.com/jbogard/MediatR). MediatR supports request/response, commands, queries, notifications and events, synchronous and async with intelligent dispatching via C# generic variance.


I prefer to use MediatR as my implementation of choice of the Mediator Pattern, because of its ease of use and versatility. I also learned alot about code by reading the MediatR source code. It is well worth cloning the repository and spending sometime just going through the implementation, it will provide one with a good sense of how to implement the pattern and also an appreciation of some of the finer points of the C# language.
I prefer to use MediatR as my implementation of choice of the Mediator Pattern, because of its ease of use and versatility. I also learned a lot about code by reading the MediatR source code. It is well worth cloning the repository and spending sometime just going through the implementation, it will provide one with a good sense of how to implement the pattern and also an appreciation of some of the finer points of the C# language.

### Why use the Mediator pattern
When working with Domain Classes where multiple functions are used to modify state and implement domain rules it usually becomes difficult to debug, extend and review the implementation. Often business rule functions implement multiple sub-rules that are repeatedly required elsewhere in the domain. This may lead to Multiple layers of complex abstraction required to share functionality or multiple strategies from several developers advocating different patterns and practices.
Expand Down Expand Up @@ -47,7 +47,9 @@ Once you have [installed the template](https://www.nuget.org/packages/threenine.
```c#
dotnet new apiproject -n mediator
```
Once the project has been generated, we will have have all that is required done for us to provide the most simplistic example of the Mediator pattern.
Once the project has been generated, we will have have all that is required done for us to provide the most simplistic example of the Mediator pattern.

**The Sample project is also generated using what is known as [Vertical Slice Architecture](https://jimmybogard.com/vertical-slice-architecture/)**

It is important that the basis of the Mediator pattern, is Request & Response mediation.

Expand Down
26 changes: 13 additions & 13 deletions Mediator/mediator.sln
Expand Up @@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.6.30114.105
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "mediator", "src\mediator\mediator.csproj", "{5A618FF8-6FAD-4261-8C8A-9C2FB58CA224}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "mediator", "src\mediator\mediator.csproj", "{468A2BB9-1240-42E1-BFB7-2AC7D738CF54}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand All @@ -18,17 +18,17 @@ Global
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{5A618FF8-6FAD-4261-8C8A-9C2FB58CA224}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5A618FF8-6FAD-4261-8C8A-9C2FB58CA224}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5A618FF8-6FAD-4261-8C8A-9C2FB58CA224}.Debug|x64.ActiveCfg = Debug|Any CPU
{5A618FF8-6FAD-4261-8C8A-9C2FB58CA224}.Debug|x64.Build.0 = Debug|Any CPU
{5A618FF8-6FAD-4261-8C8A-9C2FB58CA224}.Debug|x86.ActiveCfg = Debug|Any CPU
{5A618FF8-6FAD-4261-8C8A-9C2FB58CA224}.Debug|x86.Build.0 = Debug|Any CPU
{5A618FF8-6FAD-4261-8C8A-9C2FB58CA224}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5A618FF8-6FAD-4261-8C8A-9C2FB58CA224}.Release|Any CPU.Build.0 = Release|Any CPU
{5A618FF8-6FAD-4261-8C8A-9C2FB58CA224}.Release|x64.ActiveCfg = Release|Any CPU
{5A618FF8-6FAD-4261-8C8A-9C2FB58CA224}.Release|x64.Build.0 = Release|Any CPU
{5A618FF8-6FAD-4261-8C8A-9C2FB58CA224}.Release|x86.ActiveCfg = Release|Any CPU
{5A618FF8-6FAD-4261-8C8A-9C2FB58CA224}.Release|x86.Build.0 = Release|Any CPU
{468A2BB9-1240-42E1-BFB7-2AC7D738CF54}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{468A2BB9-1240-42E1-BFB7-2AC7D738CF54}.Debug|Any CPU.Build.0 = Debug|Any CPU
{468A2BB9-1240-42E1-BFB7-2AC7D738CF54}.Debug|x64.ActiveCfg = Debug|Any CPU
{468A2BB9-1240-42E1-BFB7-2AC7D738CF54}.Debug|x64.Build.0 = Debug|Any CPU
{468A2BB9-1240-42E1-BFB7-2AC7D738CF54}.Debug|x86.ActiveCfg = Debug|Any CPU
{468A2BB9-1240-42E1-BFB7-2AC7D738CF54}.Debug|x86.Build.0 = Debug|Any CPU
{468A2BB9-1240-42E1-BFB7-2AC7D738CF54}.Release|Any CPU.ActiveCfg = Release|Any CPU
{468A2BB9-1240-42E1-BFB7-2AC7D738CF54}.Release|Any CPU.Build.0 = Release|Any CPU
{468A2BB9-1240-42E1-BFB7-2AC7D738CF54}.Release|x64.ActiveCfg = Release|Any CPU
{468A2BB9-1240-42E1-BFB7-2AC7D738CF54}.Release|x64.Build.0 = Release|Any CPU
{468A2BB9-1240-42E1-BFB7-2AC7D738CF54}.Release|x86.ActiveCfg = Release|Any CPU
{468A2BB9-1240-42E1-BFB7-2AC7D738CF54}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal
36 changes: 0 additions & 36 deletions Mediator/src/mediator/Activities/Sample/Get.cs

This file was deleted.

23 changes: 0 additions & 23 deletions Mediator/src/mediator/Handlers/Sample/GetSampleHandler.cs

This file was deleted.

41 changes: 0 additions & 41 deletions Mediator/src/mediator/Program.cs

This file was deleted.

11 changes: 0 additions & 11 deletions Mediator/src/mediator/Requests/Sample/SampleRequest.cs

This file was deleted.

8 changes: 0 additions & 8 deletions Mediator/src/mediator/Responses/Sample/SampleResponse.cs

This file was deleted.

53 changes: 0 additions & 53 deletions Mediator/src/mediator/Startup.cs

This file was deleted.

25 changes: 0 additions & 25 deletions Mediator/src/mediator/appsettings.Development.json

This file was deleted.

3 changes: 0 additions & 3 deletions Mediator/src/mediator/appsettings.json

This file was deleted.

37 changes: 0 additions & 37 deletions Mediator/src/mediator/mediator.csproj

This file was deleted.

0 comments on commit 10c48ea

Please sign in to comment.