question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Send common command (query) object and get object response

See original GitHub issue

Pleace add such functionality:

object query  = Activator.CreateInstance(requestType);
object response = Mediator.Send(query);
if(response is SomeType resp) 
{
 //...
}

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:21 (10 by maintainers)

github_iconTop GitHub Comments

3reactions
jbogardcommented, Jul 1, 2019

Oh, I was waiting for a PR. @twadrianlis go ahead and open one!

0reactions
vip32commented, Aug 25, 2019

Yes, have the same case (command from json deserialization) glad I found this thread ✌️

On Fri, Aug 23, 2019, 12:05 Remco Ros notifications@github.com wrote:

the extension in the PR works nice though

public static class MediatorExtensions { public static async Task<object> Send(this IMediator mediator, object request, CancellationToken cancellationToken = default) { return await mediator.Send((dynamic)request, cancellationToken); } }

I have been doing this for years in one of our (plugin extendable) webservices.

  • Have a registry of command names + .NET types. (plugins can register new command names + their type)
  • on http request of a command, lookup it’s .NET type by command name
  • use JSON deserializer to deserialize to that type
  • because it’s all runtime, you get back an ‘object’ from the serializer,
  • using that MediatR extension I send the command (object) to mediatr

Works like a charm

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/jbogard/MediatR/issues/385?email_source=notifications&email_token=AABIDT7Y7ZO4VQIKTGCF7G3QF6Y67A5CNFSM4HAVKB62YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD47YLSQ#issuecomment-524256714, or mute the thread https://github.com/notifications/unsubscribe-auth/AABIDT2WID52U6N2PCQNVO3QF6Y67ANCNFSM4HAVKB6Q .

Read more comments on GitHub >

github_iconTop Results From Across the Web

query-objects — AWS CLI 1.29.30 Command Reference
The query that defines the objects to be returned. The Query object can contain a maximum of ten selectors. The conditions in the...
Read more >
write-get-object-response — AWS CLI 1.29.26 Command ...
A standard MIME type describing the format of the object data. This header can be used as a data integrity check to verify...
Read more >
RESTful API. Should I be returning the object that was ...
I'm designing a RESTful web service using WebApi and was wondering what HTTP responses and response bodies to return when updating / creating ......
Read more >
HTTP headers and common query string parameters for ...
A response header that contains the entity tag of the object being accessed. ... can be sent with a POST command in order...
Read more >
Using the Fetch API - MDN Web Docs
The Fetch API provides a JavaScript interface for accessing and manipulating parts of the protocol, such as requests and responses.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found