Move interfaces to its own assembly
See original GitHub issueIt would be nice to have all the interfaces and base classes (such as Unit) moved to it’s own assembly, called MediatR.Abstractions or something like that, so we could use it in class libraries without having a dependency on the concrete implementation.
For example I have a shared projet, called Domain.Shared where I share commonly used interfaces and classes (such as IEntity<T>
etc.) that I’d like to share accross multiple microservices, each implementing it’s own Requests and Notifications.
This is a small problem, as if I want to use a newer versions of MediatR in one of the microservices, I’d have to update all the services, when I update Domain.Shared project.
Since the interfaces rarely change, it would make sense to extract them, so our class libraries only depend on the abstractions and we only have to reference the MediatR package in the application projects (ASP.NET 5, MVC, Console Application) and not in our class libraries. Then we could use individual verisons in our microservices, like having MediatR 2.0 on OrderService and having maybe 2.0.2 on ShippingService for example
Issue Analytics
- State:
- Created 8 years ago
- Comments:21 (8 by maintainers)
Top GitHub Comments
Early on I considered moving the contracts out, but a few reasons why I didn’t:
@iuribrindeiro I don’t mean to speak for Mr. Bogard here but I don’t think MediatR should ever seep up into the browser. I get where you’re coming from because it’s nice to write a single request schema and share it between the client and the server. Given that the IRequest interfaces are all just marker interfaces you are far better off defining the request object in your Blazor client assembly and since your server has a reference to it simply inheriting from the client request class on the server and having the sever version implement the marker interface. Your controller then just takes the server version which is structurally the same and passes it off to MediatR and you get the benefits you’re looking for while keeping the browser footprint as small as possible.