mediatr

Why doesn't Mediatr resolve method when entites are in different projects?

两盒软妹~` 提交于 2020-05-26 13:38:04
问题 I have a simple project to try out Mediatr issue. When the concrete class of my handler in the SAME project of my API, it WORKS. But, when I take that handler class in to a different project (and API references that project ofc), it does NOT resolve the registry. I'm getting this error: Handler was not found for request of type MediatR.IRequestHandler`2[MyBiz.GetTokenModelRequest,MyBiz.TokenModel]. Register your handlers with the container. See the samples in GitHub for examples. I have this

How to add MediatR PublishStrategy to existing project

|▌冷眼眸甩不掉的悲伤 提交于 2020-03-02 20:02:58
问题 Now I use MediatR notifications like this: private readonly IMediator _requestsRouter; // from constructor injection OrderCreatedEvent orderCreatedEvent = new OrderCreatedEvent(x,y,z); await _requestRouter.Publish(orderCreatedEvent); I would like to change default PublishStrategy to ParallelNoWait = 3, Question: How to extend MediatR functionality from nuget with MediatR PublishStrategies from sample ? I understand that I can download MediatR source code, add to it code from MediatR.Examples

Mediatr: reducing number of DI'ed objects

亡梦爱人 提交于 2020-01-15 03:53:08
问题 I have a lot of commands and queries and most of them need same interfaces DI'ed to do different things. Is it possible to some how reduce this clutter that each and every one of my handler needs and it is repeated over and over? public class GetCoinByIdQueryHandler : IRequestHandler<GetCoinByIdQuery, CoinModel> { private readonly EventsContext context; private readonly ICacheClient cache; private readonly ILogger logger; private readonly IMapper mapper; private readonly Settings settings;

How to decouple MediatR from my business layer

懵懂的女人 提交于 2020-01-06 05:50:15
问题 Good morning. I'm using domain events in my project, and the easiest way i found to implement it was by using MediatR. But i don't want my project to directly depend on it, i want apply dependency inversion to hide the library. Current code that has a dependency in Mediator, because of INotification interface public class EmailConfirmedEvent : INotification { public Guid PassengerId { get; } public string Email { get; } public EmailConfirmedEvent(Guid passengerId, string email) { Email =

Is MediatR a good fit for updating multiple MongoDB read models?

江枫思渺然 提交于 2020-01-05 05:49:06
问题 On a recent project, I used NServiceBus to update multiple (typically two) MongoDB read models as a result of commands initiated by users. After reading more about MediatR it seems like, as the read models are part of this application (i.e. no other services are consuming the ISomethingHappened events), NServiceBus was probably overkill here. That said, the guaranteed delivery and retries that NServiceBus provides aren't necessary with MediatR, however for most applications, I can't afford to

Is it possible to implement MediatR in the Aggregates (Domain Layer) without dependency injection (DDD)?

不羁岁月 提交于 2020-01-02 10:23:18
问题 To prevent reinventing the wheel, I'd like to use MediatR in the Aggregates to publish domain events. (Un)Fortunately(?) MediatR works as a dependency that is injected into the classes, and not something that I can call statically. Therefore I'd end up creating a direct dependency on the library via the constructor. I don't remember where I read it (and if I read it right), that I should avoid non-business dependencies in the constructors of the Aggregates. Therefore, I shouldn't do something

Is it possible to implement MediatR in the Aggregates (Domain Layer) without dependency injection (DDD)?

给你一囗甜甜゛ 提交于 2020-01-02 10:22:19
问题 To prevent reinventing the wheel, I'd like to use MediatR in the Aggregates to publish domain events. (Un)Fortunately(?) MediatR works as a dependency that is injected into the classes, and not something that I can call statically. Therefore I'd end up creating a direct dependency on the library via the constructor. I don't remember where I read it (and if I read it right), that I should avoid non-business dependencies in the constructors of the Aggregates. Therefore, I shouldn't do something

DryIOC and MediatR: Injection using InResolutionScopeOf for both IAsyncNotificationHandler and IAsyncRequestHandler

守給你的承諾、 提交于 2019-12-24 08:12:24
问题 This question is a follow up to my previous question, DryIOC Decorator and InResolutionScopeOf What I'm trying to do is create EF DbContext instances in the resolution scope of both IAsyncRequestHandler and IAsyncNotificationHandler, meaning the context injected in a request can't be the same as one injected in a notification (published from a request). Since the notifications are published from inside the request handlers, this nesting is creating some troubles with my desired setup. It is

Dependency Scope Issues with MediatR and SimpleInjector

一笑奈何 提交于 2019-12-13 14:12:25
问题 I've been experimenting with the mediator pattern and CQRS using the MediatR library in a WinForms application that uses the Entity Framework for data access. The application is used in a batch manufacturing plant, and allows users to see a list of active and completed batches, and if necessary make updates to batch information. Each batch has a large amount of information associated with it, such as quality and process measurements. Reading and writing data is organized into Queries and

Register a MediatR pipeline with void/Task response

送分小仙女□ 提交于 2019-12-12 10:47:35
问题 My command: public class Command : IRequest { ... } My handler: public class CommandHandler : IAsyncRequestHandler<Command> { ... } My pipeline registration (not using open generics): services.AddTransient<IPipelineBehavior<Command>, MyBehavior<Command>>(); However this doesn't work: Using the generic type 'IPipelineBehavior<TRequest, TResponse>' requires 2 type arguments. And same error for MyBehavior . The docs mention the Unit struct. How do I use it? 回答1: As Mickaël Derriey pointed out,