question

Andrej avatar image
0 Votes"
Andrej asked AgaveJoe edited

Trace the source that triggered the event

Hello, I have an Asp.Net Core Web API, witch CQRS(we use MediatR). How, for debugging purposes, define the source(ClassName, MethodName) that triggered the event. Because one handler can be used in several places and this makes debugging more difficult.
For example:

 public class SomeClass
 {
    public void Method1()
    {
        //..do something
        AddEvent(new **MyEvent**());
    }
    
    public void Method2()
    {
        //..do something
        AddEvent(new **MyEvent**());
    }
 }




dotnet-csharpdotnet-aspnet-core-webapi
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

I'm not familiar with the open source GitHub MediatR project. There is nothing stopping you from taking a look at the source code, reading the Wiki, or reaching out to the project developer for assistance. This might be the best approach for getting help with MediatR.

I am familiar with C# event. The standard event handler pattern has the sender input parameter which indicates the event originator.

Events (C# Programming Guide)
How to subscribe to and unsubscribe from events (C# Programming Guide)

If you are trying to figure out what client called a Web API action then that's more of a model question or security.


0 Votes 0 ·

0 Answers