Skip to content

Latest commit

 

History

History

README.md

MediatorDesignPatternExamples - Mediator Pattern in C# with Manual and MediatR Implementations

YouTube Blog Newsletter All Links LinkedIn

This .NET 7.0 solution demonstrates the Mediator design pattern through two parallel implementations of a chat application. The MediatorChatConsoleApp project provides a manual implementation where a ChatMediator class registers users and routes messages between them, demonstrating the core concept of decoupling communication between components through a central mediator object.

The MediatrConsoleApp project implements the same chat functionality using the popular MediatR NuGet library (v12.2.0) with Microsoft.Extensions.DependencyInjection. It uses IRequest and IRequestHandler<T> to dispatch ChatMessage requests through the mediator pipeline, showcasing an enterprise-ready approach with full async support and dependency injection integration. Comparing the two implementations side by side highlights the trade-offs between simplicity and scalability when choosing between manual and library-based mediator patterns.

Getting Started

Prerequisites

  • .NET 7.0 SDK or later

Running the Project

cd MediatorDesignPatternExamples/MediatorChatConsoleApp
dotnet run

Related Resources

Blog Articles

Newsletter

If you found this useful and you want to learn more about C#, .NET, and software engineering, subscribe to the free Dev Leader Weekly newsletter:

Subscribe to Dev Leader Weekly

Connect with Dev Leader


BrandGhost

Powered by BrandGhost 👻