Skip to content

snavarropino/MediatrSamples

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MediatrSamples

Samples of Mediatr v4 usage. In order to know what Mediatr is please visit https://github.com/jbogard/MediatR

This solution contains two projects:

  • An Asp.Net Core MVC website, that has a concrete action in a controller that is going to use Mediatr.

    Controller: HomeController

    Action: Index

    So to start the interaction with Mediatr please invoke /home/index

  • A library that exposes commands, responses, handlers and events.

Once the action is invoked, different interactions with Mediatr will happend:

  1. A command, handled by an asynchronous handler, is sent. Response is received
  2. A command defined with no response is handled by an asynchronous handler
  3. A command, handled by an asynchronous handler with no cancellation token, is sent. Response is received
  4. Several handlers are defined for same command. Just one of them is executed.
  5. A command is send and then handled by an synchronous handler. Response is received
  6. An event is sent and is managed by 2 listeners
  7. An event is sent and is managed by 2 different listeners: one with no cancellation token and another one thar works in a synchronous way
  8. A listener that will handle all sorts of events is defined

In addition, there are some examples os pipeline behaviours usage. They are in following files:

  • 9_APipelineBehaviour.cs

    Here we can found 2 different behaviours that allow us to inject code before a command is handled and after it is handled

    In order to see them working please uncomment logs inside the file

    In addition we also try to define a specialized behaviour (for just one concrete command). Unfortunatelly this is not working

  • 9_bis_PostProcessor

    Here we can found a postprocessor that allow us to inject code that will be executed after a command is handled

    In order to see them working please uncomment logs inside the file

Behaviours are defined in asp.net core startup class

About

Samples of Mediatr v4 usage

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published