-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Generic types with MediatR #69
Comments
That's possible today in MediatR, provides your handler factory knows how On Wednesday, February 17, 2016, Dan C notifications@github.com wrote:
|
Thanks for the speedy response @jbogard! I've got this working by explicitly registering the in StructureMap, like so:
Is there a way to register this in StructureMap to handle all object types passed in? Something along these lines:
|
From 6 year younger @jbogard: Advanced StructureMap: connecting implementations to open generic types 😉 |
@khellang I'd attempted to use that method from that article without much luck :(
where what I'm trying to achieve is this:
Here's a snippet of what I've got in a single test - any help would be greatly appreciated.
When looking at WhatDoIHave() - I can see the IRequestHandler in there:
However, when calling it, I get the following error: Any ideas how to configure this with structuremap please @jbogard @khellang? |
I think you'll have to ask the StructureMap people on this one. But likely On Thursday, February 18, 2016, Dan C notifications@github.com wrote:
|
Ok thanks @jbogard. Will report back findings. |
@dannyc02 See this http://structuremap.github.io/generics/ and this http://structuremap.github.io/registration/auto-registration-and-conventions/. I'd urge you to be cautious about doing this though. You could easily get into a situation where the team just isn't going to be able to unravel the very fancy generics auto-registrations. |
@jeremydmiller thanks for the info, really helped. I managed to get it working using a custom convention, gist here: https://gist.github.com/dannyc02/6d42b90154d8478dc6fd |
Hi @jbogard ,
I was wondering if it's possible to extend this framework to handle generic types in requests? Here's an example of what I was hoping to achieve:
mediator.Send(new CreateItemCommand<ItemType>(item))
public class CreateItemCommand<TItemType> : IRequest<T> where T: ISomeInterface
(Apologies if this isn't the correct place to ask this question.)
The text was updated successfully, but these errors were encountered: