Questions tagged [mediatr]

MediatR is a simple, open source mediator implementation in .NET.

MediatR is a simple, open source, mediator implementation in .NET

A low-ambition library trying to solve a simple problem - decoupling the in-proc sending of messages from handling messages. Cross-platform, supporting .NET 4.5, .NET Standard 1.3, and .NET Standard 2.0.

Supports request/response, commands, queries, notifications and events, synchronous and async with intelligent dispatching via C# generic variance.

See https://github.com/jbogard/MediatR/wiki for more details.

507 questions
0
votes
1 answer

Dependency Injection with XUnit Mediatr and IServiceCollection

Currently I'm able to handle IServiceCollection to inject mocks for particular services in the following manner. public class TestClass { private IMediator _mediatr; private void SetupProvider(IUnitOfWork unitOfWork, ILogger logger) { …
Fernando
  • 614
  • 1
  • 9
  • 20
0
votes
1 answer

How is Mediatr wired?

Update: The Mediatr in the project is used without any customized logic for dispatching the messages. Can I say it's used as an event aggregator? In the source code of https://github.com/JasonGT/NorthwindTraders, the Controller gets the Mediator…
ca9163d9
  • 27,283
  • 64
  • 210
  • 413
0
votes
1 answer

SignalR Hub sending message but no clients receive it

I have a aspnetcore Mvc website which is running a QuartzNet Scheduler. The Scheduler has listeners which are triggered when a Job is executing and has been executed. The listener is using MediatR to publish a message which is then being handled by…
gwinnem
  • 66
  • 4
0
votes
0 answers

What I misunderstood about the Mediator Pattern?

I'm new here and a beginner architect. I'm helping the company I work to design our new product and since I start it, I read a lot about but is never enough. I decided to use Mediator Pattern (with Mediatr) to call my application layer. It's cool…
0
votes
0 answers

.NET Core scoped dependency injection not working with MediatR

Consider the following code: Startup.cs public static void RegisterServices(IServiceCollection services) { services.AddSingleton(); services.AddTransient(); // Empty/dummy interface and class …
boots
  • 51
  • 4
0
votes
1 answer

ASP.NET Core API, Mediatr send method raises exception unable to resolve service for type

I have a ASP.NET Core API, where I am trying to use FluentValidation with Mediatr. Currently when the controller method is attempting to call Send on the mediatr instance it generates: Exception thrown: 'System.InvalidOperationException' in …
DevOverflow
  • 491
  • 1
  • 5
  • 16
0
votes
2 answers

Execute a method after some inactivity using Rx .Net

I have a Controller Action like this: [HttpPost("Post")] public async Task Post([FromBody] UpdateDataCommand command) { await _mediator.Send(command); } It is done in .Net Core, and is using MediatR to process commands. Now, the…
Luka
  • 4,075
  • 3
  • 35
  • 61
0
votes
1 answer

Inject dependencies in Mediatr command handler

I am using Autofac and mediatr. The flow is a message coming from EventHub and I process it and send it to respective command handlers. I can inject few things from the api projects perspective, using the builder. builder.Register(ctx => { var…
HariHaran
  • 3,642
  • 2
  • 16
  • 33
0
votes
1 answer

How should I handle Simple Injector Lifestyles for MediatR NotificationHandlers?

I have an ASP.NET Web API using MediatR and SimpleInjector. They are registered like this: _container.Options.DefaultScopedLifestyle = new AsyncScopedLifestyle(); _container.Options.DefaultLifestyle =…
Steve Dunn
  • 21,044
  • 11
  • 62
  • 87
0
votes
1 answer

Azure Function Queue triggered with Mediatr - DbContext error

I'm implementing Queue triggered azure function - I'm using a Mediator Pattern library called Mediatr for enhancing command query segregation - and using the latest run-time (2.0.12382.0) constructor dependency injection in Azure Function according…
0
votes
1 answer

Figure out whether MediatR notification handler implements a custom interface

I'm using MediatR to publish notifications. I have defined a notification handler as follows: public class TestNotificationHandler : INotificationHandler, IWithinTransaction { public Task Handle(TestNotification notification,…
L-Four
  • 13,345
  • 9
  • 65
  • 109
0
votes
1 answer

Mediatr Notifications on ViewModel in WPF MVVM

While implementing a WPF Application I stumbled on the problem that my application needs some global data in every ViewModel. However some of the ViewModels only need reading access while other need read/write access for this Field. At First I…
Brezelmann
  • 359
  • 3
  • 16
0
votes
1 answer

Integrate Autofac with mediatr ASP.NET Web API2

I develop an app on asp.net api2 with autofac and mediatR, currently facing some issue with the dependency injection. // This is registered in the global.asax file and working properly in the controller level //i'm trying to register the entity…
Jend DimShu
  • 87
  • 1
  • 5
0
votes
2 answers

How do I perform a query and then a command based on the query's result with MediatR?

I am attempting to use the MediatR library to implement a command pattern in my net core web API, however, I am unsure how to proceed. I have a situation where when a user attempts to registers an account, the API should check the database for a…
0
votes
0 answers

How does one set a variable in a command using Mediatr with Moq?

I have a simple functional style test for output of a command that I've written using Mediatr's IRequest and IRequestHandler<> [Fact] public void TestReturnValuesAsync() { // Arrange var handler = new…
CSharpMinor
  • 202
  • 1
  • 9