martinothamar / Mediator

A high performance implementation of Mediator pattern in .NET using source generators.
MIT License
2.01k stars 69 forks source link

Multilayered app problem #125

Open GunesElektronik opened 7 months ago

GunesElektronik commented 7 months ago

I have an application in clean architecture. I wanted to switch from Mediatr to Mediator for performance reasons. But there is a problem here. The problem is that Mediator forces our objects to be in the same project as the Library. Will there be a solution for this?

adrskw commented 7 months ago

You should install Mediator.SourceGenerator in the outermost project and then install Mediator.Abstractions in all remaining projects that define handlers: https://github.com/martinothamar/Mediator#3-usage-and-abstractions

GunesElektronik commented 7 months ago

Thanks, I will try it.

vdboots commented 6 months ago

it seems that it won't work. on 2.1.7

martinothamar commented 6 months ago

Hi! Need more specifics to understand what's going wrong. In the meantime, here are some samples showing various ways to organize multiple projects, including clean-architecture style:

RealHustengutzel commented 4 months ago

Hi. I have the same problem.

I’m trying to publish a notification in my Application.Core Project and catch this notification in my Demo.Server.

Project Overview:

Demo.Server (references Application.Core) with Mediator.Abstractions 2.1.7 Application.Core with Mediator.Abstractions 2.1.7 and Mediator.SourceGenerator 2.1.7 and is adding AddMediator() to a IServiceCollection.

My Application.Core is publishing a notification (for example, DeviceStatusChanged) and also has a consumer for this. My Demo.Server also has a consumer for (DeviceStatusChanged) but never receives this notification."

I hope this helps! If you have any other questions or need further assistance, feel free to ask.

eminvergil commented 2 months ago

There is an example for multi handler scenarios.

https://github.com/martinothamar/Mediator/blob/d79a4616af843713e0b634f04652a9a42f2063f4/test/Mediator.SourceGenerator.Tests/resources/DuplicateHandlersProgram.cs

Hi. I have the same problem.

I’m trying to publish a notification in my Application.Core Project and catch this notification in my Demo.Server.

Project Overview:

Demo.Server (references Application.Core) with Mediator.Abstractions 2.1.7 Application.Core with Mediator.Abstractions 2.1.7 and Mediator.SourceGenerator 2.1.7 and is adding AddMediator() to a IServiceCollection.

My Application.Core is publishing a notification (for example, DeviceStatusChanged) and also has a consumer for this. My Demo.Server also has a consumer for (DeviceStatusChanged) but never receives this notification."

I hope this helps! If you have any other questions or need further assistance, feel free to ask.

Can you produce a sample project ?